NServiceBus.GenericHost Exception when starting endpoint - Unable to load one or more types

Using NSB 6.4.3 with RabbirMQ 4.4.5

I have a solution with multiple projects, all project loads up fine except for one that gives this error message.
When I press F5 to debug it, the console window closes immediately and no breakpoint gets hit.

try debugging with “break on all exceptions” enabled Visual Studio - Break On All Exceptions

Hi,

It’s look like something with project assembly reference. Maybe below links will help:

… and this a little bit older topic with similar problem that could be also helpful somehow:

Well, now it shows me that it is missing some nuget packages which is strange because they are not used in this project. But still, I started to install every nuget that it asked and it is stuck with asking for Newtonsoft.Json version 10.0.0.0, so I’ve installed it and on the next run it asks for Newtonsoft.Json version 11.0.0.0 so I’ve updated it and on the next run it asks for the Newtonsoft.Json version 10.0.0.0 again and so on… It is stuck in this loop…

Any ideas?

I’ve already seen those links, they all suggest to move the binding redirects from the app.config file to the NServiceBus.Host.exe.config. file
The solution I’m working on has many class library projects that all run NServiceBus.Host.exe and none of them has a file called NServiceBus.Host.exe.config except for the project that I’m having this issue with. This project does have an NServiceBus.Host.exe.config file so I moved this section from the app.config file to the NServiceBus.Host.exe.config file:

    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="NServiceBus.Core" publicKeyToken="9fc386479f8a226c" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>     
      <dependentAssembly>
        <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.4000" newVersion="4.1.0.4000" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="AutoMapper" publicKeyToken="be96cd2c38ef1005" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.2.1.0" newVersion="6.2.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.110.0" newVersion="1.0.110.0" />
      </dependentAssembly>
    </assemblyBinding>
    </runtime>

And it didn’t solve it.
Any ideas?

In this kind of scenarios it’s very hard to help without access to source code and knowing what are you exactly doing migrating the code so maybe the best way you can do is to start from the beginning:

  • You have the project X with NServiceBus 6.4.3. with MSMQ Transport.
  • The project has package NServiceBus.Host 7.x and other project references/nuget packages.
  • I assume that in this configuration Host starts properly.
  • Then you install NServiceBus RabbitMQ 4.4.5, configure transport settings and press F5.
  • Do you receive mentioned exception at this moment ?

I simulate this kind of migration scenario on the NServiceBus Host sample and I don’t have Host exception.

After that you can make another simple migratoin change and test and another simple change and test and so on until you’ll receive Host exception. At this point in time you’ll know wchich change is problematic so it’s shuld be easeir to find the reason and solution eventually.

Hope this help somehow.