How does NServiceBus know which DLL to use?

92 views Asked by At

This is not a problem, but a question for me to understand the "magic" that happens in NserviceBus

I have a working environment where a NServiceBus-Service is called that way:

"D:\Service\NServiceBus.Host.exe" -service  /serviceName:"MyServiceAdapter" /endpointName:"MyQueue.Adapter"

Now inside the same directory there is my application "My.Adapter.dll" which also has a config. There is NO NserviceBus.config anywhere. Still: The NserviceBus seems to know that it has to use "My.Adapter.dll"

Why does NServiceBus know that? I did not find any reference in the Queue (MSMQ) or anywhere else to my application. Is it saved in the registry? If yes: Where?

1

There are 1 answers

0
Alexey Zimarev On

By default NServiceBus scans all assemblies that are located in the same folder with NServiceBus.Host.exe and looks for its own markers (interfaces) like IWantCustomInitialization, IHandleMessage and so on. It either uses its default IoC container builder (Autofac) or the one that you supply.

You can also limit, which assemblies will be scanned by using Configure.With(assemblies) for V4 and configuration.AssembliesToScan(myListOfAssemblies) for V5.

More to read here http://docs.particular.net/nservicebus/assembly-scanning