Skip to content

Latest commit

 

History

History
52 lines (29 loc) · 2.12 KB

assembly-scanning.md

File metadata and controls

52 lines (29 loc) · 2.12 KB
title summary tags
Assembly scanning in NServiceBus
To enable automatic detection of various features NServiceBus scans your assemblies for well known types

By default, NServiceBus scans all assemblies in the endpoint bin folder to find types implementing its interfaces so that it can configure them automatically.

NOTE: During the scanning process, the core dlls for NServiceBus namely NServiceBus.Core.dll, NServiceBus.dll (in versions prior to Version 5) and if in use NServiceBus.Host.exe are automatically included since the endpoint needs them to function properly.

Controlling the assemblies to scan

There are some cases where you need fine grained control over which assemblies are loaded:

  • To limit the number of assemblies being scanned and hence provide improvements to startup time.
  • If you are hosting multiple endpoints out of the same directory (made possible in Version 5) i.e. each endpoint would want to load a subset of assemblies.
  • In versions prior to Version 4.1, non .NET assemblies, e.g. COM dlls might need to be excluded. Starting with Version 4.1, non .NET assemblies are automatically excluded.

NOTE: Extension (like NServiceBus.Distributor.MSMQ.dll or NServiceBus.RavenDB for example) are not considered core dlls and will need to be explicitly added if you customize assembly scanning.

By default all types in your bin directory are scanned if you call:

You can pass a list of assemblies:

You can pass the assemblies one by one:

###You can exclude specific assemblies by name:

You can include assemblies using pattern matching:

You can mix includes and excludes:

You can specify the directory to scan:

And if you need to control the exact types that NServiceBus uses you can pass them in: