The dreaded “No endpoint configuration found in scanned assemblies” NServiceBus error

nservicebus

Background:

  • I have two NServiceBus endpoint projects in my solution.
  • Both are NServiceBus subscribers and contain a message handler to one message.
  • Each subscriber project handles a message from one of two different publishers. As such, one project references a messages DLL from one publisher, and the other references a messages DLL from the other publisher.
  • Both publishers are external to my solution.
  • Apart from the messages DLLs, both subscriber projects reference the same binaries for NServiceBus, and additionally have the exact same setup (UnicastBusConfig, EndpointConfig, appSettings, etc)

One subscriber project runs fine, but the other one fails with this error:

Unhandled Exception: System.InvalidOperationException: No endpoint configuration found in scanned assemblies. This usually happens when NServiceBus fails to load your assembly contaning IConfigureThisEndpoint. Try specifying the type explicitly in the NServiceBus.Host.exe.config using the appsetting key: EndpointConfigurationTypeScanned path: my path here
at NServiceBus.Host.Program.ValidateEndpoints(IEnumerable`1 endpointConfigurationTypes)
at NServiceBus.Host.Program.GetEndpointConfigurationType()
at NServiceBus.Host.Program.Main(String[] args)

My suspicion is that the problem must lie with the NServiceBus publisher messages DLL of the subscriber which is failing to start up. Howerver, I am not sure how to work out what is wrong with this. I have looked at:

  • both the NServiceBus publishers messages DLL's manifests using ildasm and they are identical (with regards to processor flags and NServiceBus DLL versions referenced).
  • the NSB messages projects, which were both built with .Net 3.5 Framework.

I am going insane here and have burned almost a day trying to get this working. Any help would be massively appreciated.

Best Answer

Well, the exception tells you exactly what it is about. It is looking for some class that implements IConfigureThisEndpoint.

Three things come to my mind:

  • You forgot to implement it (have a look at the NServiceBus samples)
  • You implemented it but your class is not public or internal
  • You have more than one assembly in the folder or subfolder in which your files are located that implement IConfigureThisEndpoint
  • You have a mismatch between the framework versions of your assemblies and the NServiceBus assemblies, i.e. you're using NServiceBus compiled for .NET 3.5 but Visual Studio 2010 created your endpoint (by default) as .NET 4.0. (point added by David Boike)
  • The messages DLL the failing subscriber is referencing is delay-signed. This is causing it to fail with the "No endpoint configuration found..." error. Build a strong named version of the messages DLL locally solves the problem. (point added by thecolour)
  • The "No endpoint config..." exception seems to be thrown for lots of different reasons, and it kind of masks the actual reason. The exception basically only says that the configuration could not befound, it does not specify what is the original cause of the problem. (point added by thecolour)
  • The NServiceBus version that we use is not compiled against .NET v4. So we need to create a config file NServiceBus.Host.exe.config that configures the .NET version to be used.
    • Do not forget to set the afore mentioned NServiceBus.Host.exe.config file to be copied into the /bin/Debug folder in the properties windows. Happens to me all the time... ;-)

The NServiceBus.Host.exe.config file should look like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <startup>
      <supportedRuntime version="v4.0" />
   </startup>
   <runtime>
       <loadFromRemoteSources enabled="true" />
    </runtime>
</configuration>

I think that the "No endpoint config..." exception seems to be thrown for lots of different reasons, and it kind of masks the actual reason. Anyone know a nice way of diagnosing these kind of problems?

The last point happend to me, too. It happended after renaming my assembly and not cleaning the project directory. NServiceBus then ran through all files and found both the old named assembly AND the new named assembly and ended with the same exception.

Please note that this also happens if the second assembly containing the same interface implementation may cause tis error if it is located inside a subfolder. This behaviour had caused me some debugging headaches as I previously had copied my file to a subfolder as a short term backup...

[Edit]

Edited to add the additional items by the other authors in this thread for completeness.

[EDIT 2]

Added more information about NServiceBus.Host.exe.config.

Related Topic