Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The dreaded "No endpoint configuration found in scanned assemblies" NServiceBus error

Tags:

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.

like image 421
tom redfern Avatar asked May 23 '11 09:05

tom redfern


5 Answers

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.

like image 196
Jens H Avatar answered Nov 10 '22 11:11

Jens H


In my case I've got this exception because I've used NServiceBus.Host.exe from NServiceBus install path. After changed it to bin/debug copy (in both cases: server and client), program is starting correct. Project property -> Debug -> Start external program -> full path to NServiceBus.Host.exe in bin/debug folder

like image 30
squizzy Avatar answered Nov 10 '22 12:11

squizzy


OK a real face-palm moment - The messages DLL the failing subscriber was referencing was delay-signed only. This was causing it to fail with the "No endpoint configuration found..." error. Once I built a strong named version of the messages DLL locally it solved the problem.

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?

like image 45
tom redfern Avatar answered Nov 10 '22 12:11

tom redfern


I've also seen something similar when the build properties of the project were set to run on a platform target of x86.

I originally set the project up with an Output type of Console Application which caused it to be created with a platform target of x86.

I later changed the project type to be a Class Library (but failed to change the platform type to "Any CPU").

Changing the platform target to Any CPU made it start working.

like image 1
Doug Ferguson Avatar answered Nov 10 '22 12:11

Doug Ferguson


Found an additional scenario that could result in this exception that is not currently included in the accepted answer. It is specific to using Azure as the NServiceBus transport/persistence mechanism.

This error has also occurred for us when the Azure SDK is not properly installed. (How does that happen? The platform installer works great if you're getting the latest version of the SDK, but otherwise installing the SDK components individually can result in missed components.)

Digging into details: Fusion Log indicated that NServiceBus.Host.exe couldn't resolve Microsoft.WindowsAzure.ServiceRuntime.

The solution was to install all of the following components (even the emulator was needed in order to get all the dependencies resolved):

  • WindowsAzureStorageTools.msi
  • WindowsAzureEmulator-x64.exe
  • WindowsAzureTools.vs120.exe
  • WindowsAzureAuthoringTools-x64.msi
  • WindowsAzureLibsForNet-x64.msi

In our paricular case, we had to get the 2.3 version of the sdk from: http://www.microsoft.com/en-US/download/details.aspx?id=42317

Hope this information helps someone.

like image 1
MSC Avatar answered Nov 10 '22 13:11

MSC