views:

106

answers:

3

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 within 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.

A: 

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

Udi Dahan
Edited - Thanks Udi. I've verified with a co-worker that that's how we expect it to work. That is definitely not what's happening. It appears to happen inside Topshelf. I'll edit my question for completeness and the ability to use formatting.
arootbeer
+1  A: 

Hello arootbeer,

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

drusellers
I don't have a specific NServiceBus.Host.Exe.Config file for this project. However, the Main() method in NServiceBus.Host.Exe is calling ConfigureServiceInIsolation() on the IRunnerConfigurator passed to the Action<IRunnerConfigurator> in RunnerConfigurator.New(), which I assume will cause this behavior?
arootbeer
I would try running not in isolation and see if that fixes your problem. If you still want to run in isolation you can try basing your file paths off of 'AppDomain.CurrentDomain.BaseDirectory'
drusellers
The code in question is part of NServiceBus.Host.exe; I have no control over it. At least I know what it's doing now, and why. I had been planning on adding configuration-based plugin location - this just accelerated that part of the project :)
arootbeer
A: 

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.

serialseb