开发者

Why isn't NServiceBus.Host.exe running my code in place?

开发者 https://www.devze.com 2023-01-07 01:11 出处:网络
I\'m building an NServiceBus service, and when I start it (either in debug through Visual Studio, or from the command line) NServiceBus.Host.exe appears to be relocating the DLLs that it\'s running to

I'm building an NServiceBus service, and when I start it (either in debug through Visual Studio, or from the command line) NServiceBus.Host.exe appears to be relocating the DLLs that it's running to my AppData folder.

The application depends on resources that exist in the bin\debug folder (e.g. a plugins folder containing DLLs), but these resources are not being copied to the temporary folder.

My environment is Windows 7 x64, and I've tried running both Visual Studio and my command prompt as Administrator with no change in behavior.

EDIT

The behavior appears to happen wi开发者_StackOverflow中文版thin Topshelf. When I debug through with a breakpoint at the end of my endpoint's constructor, it first stops when the endpoint is constructed in the Main method of Program.cs; the environment at this point is:

? GetType().Assembly.CodeBase
"file:///C:/Projects/ProcessorService/ProcessorService/bin/Debug/ProcessorService.DLL"
? GetType().Assembly.Location
"C:\\Projects\\ProcessorService\\ProcessorService\\bin\\Debug\\ProcessorService.dll"

However, when the constructor is invoked again, this time from the GenericHost constructor, this is the environment:

? GetType().Assembly.CodeBase
"file:///C:/Projects/ProcessorService/ProcessorService/bin/Debug/ProcessorService.DLL"
? GetType().Assembly.Location
"C:\\Users\\MyUser\\AppData\\Local\\assembly\\dl3\\D5KV9218.DO9\\YOKC5KD8.C92\\4474672e\\06519009_7623cb01\\ProcessorService.DLL"

I haven't pulled down the TopShelf code to debug into that to see exactly where the dll move is taking place. But this is definitely taking place within NServiceBus.Host.Exe.


My guess would be that you are running your services in what Topshelf calls 'Isolated' mode, where we shadow copy all of your assemblies.

Could you please post your topshelf/nsb.host configuration.

-d


NServiceBus does not relocate anything, it runs entirely in the bin/debug folder (when in Visual Studio) or the installed directory when run directly.


Shadow copying is when .net copies the dlls before loading them, to enable you to update the code without locking conflicts. This looks like your culprit.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号