I am using a "custom" object builder (Autofac) so I can re-use the registration of many types that I have done in a common assembly. When I run the service, hosted within NServiceBus.Host.exe, I get the following error:
SerializationException was unhandled:
Type 'Autofac.Core.Registration.ComponentNotRegisteredException' in assembly 'Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da' is not marked as serializable.
This seems odd to me because NServiceBus uses Autofac by default and doesn't have this same issue.
I am using Autofac v 3.1.1 and NServiceBus 4.0.3
It's true that the ComponentNotRegisteredException
is not marked serializable - Portable Class Libraries don't support the SerializableAttribute
and Autofac 3.0+ is a PCL.
I'm guessing the larger issue you're running into isn't the SerializationException
so much as the problem causing it - that something in your custom code isn't registered, so when some type is getting resolved it can't be built and, thus, Autofac throws that ComponentNotRegisteredException
and NServiceBus is trying to serialize it.
Instead of trying to solve the serialization problem, I'd start looking at the source of the ComponentNotRegisteredException
and focus on that.