Easy to fix issue between NServiceBus and Code Contracts
If you use NServiceBus' Configure.With fluent interface, and you use Code Contracts in any assemblies that your NServiceBus configuration uses, then configure Code Contracts in those assemblies not to build separate code contract assemblies, because this confuses NServiceBus.
Configure.With scans all assemblies for implementations, and if any implementation you have also generates code contract assemblies, then basically you will end up with 2 assemblies that expose the same classes — one with the actual implementation, the other with the code contracts. This confuses NServiceBus and you'll get an error:
There is a component already registered for the given key
The simple solution is to go to the "offending" assembly project's Properties, select the Code Contracts tab, and in the Contract Reference Assembly dropdownlist, select "(none)" instead of "Build". The contract code will then be compiled straight into the code assembly rather than separately, and this will fix the issue with NServiceBus.















Steve Degosserie Said,
June 18, 2010 @ 8:16 am
So, how's your experience with NServiceBus so far ? You should blog about it