Upgrading from version 3 of nservicebus to version 4, and receiving the following error message
"No message serializer has been configured."
stack trace:
at NServiceBus.Unicast.UnicastBus.ValidateConfiguration() in c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 866
at NServiceBus.Unicast.UnicastBus.Start(Action startupAction) in c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 739
at NServiceBus.Unicast.UnicastBus.Start() in c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 718
at CycleMonkey.Inventory.CreateOrder.IT_OPS.CustomInit.Init() in d:\dev\backup\soa_cyclemonkey\Inventory\Inventory.CreateOrder\IT_OPS\CustomInit.cs:line 20
at NServiceBus.Hosting.Configuration.ConfigManager.ConfigureCustomInitAndStartup() in c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Hosting\Configuration\ConfigurationManager.cs:line 43
at NServiceBus.Hosting.GenericHost.PerformConfiguration() in c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Hosting\GenericHost.cs:line 126
at NServiceBus.Hosting.GenericHost.Start() in c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Hosting\GenericHost.cs:line 29
at NServiceBus.Hosting.Windows.WindowsHost.Start() in c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\hosting\NServiceBus.Hosting.Windows\WindowsHost.cs:line 56
at NServiceBus.Hosting.Windows.Program.<>c_DisplayClassd.b_5(WindowsHost service) in c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\hosting\NServiceBus.Hosting.Windows\Program.cs:line 76
at Topshelf.Internal.ControllerDelegates1.StartActionObject(Object obj) in c:\Projects\TopShelfForNSB\src\Topshelf\Internal\ControllerDelegates.cs:line 18
at Topshelf.Internal.IsolatedServiceControllerWrapper
1.<>c_DisplayClass2.b_1(TService service) in c:\Projects\TopShelfForNSB\src\Topshelf\Internal\IsolatedServiceControllerWrapper.cs:line 65
at Topshelf.Internal.ServiceController1.<.cctor>b__1(ServiceController
1 sc) in c:\Projects\TopShelfForNSB\src\Topshelf\Internal\ServiceController.cs:line 35
at Magnum.StateMachine.LambdaAction1.Execute(T instance, Event event, Object parameter) in :line 0
at Magnum.StateMachine.EventActionList
1.Execute(T stateMachine, Event event, Object parameter) in :line 0
Has something been missed in the upgrade? Version 3 of code that was working :
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server
{
}
public class CustomInit : IWantCustomInitialization
{
public void Init()
{
Configure.Instance
.CastleWindsorBuilder()
.DefaultBuilder()
.Sagas()
.RunTimeoutManagerWithInMemoryPersistence()
.ConfigureMongoSagaPersister<CreateOrderSagaData>("mongodb://localhost/create-order");
Configure.Instance
.XmlSerializer()
.MsmqSubscriptionStorage()
.MsmqTransport()
.UnicastBus();
}
}
Version 4 of the same code with the suggested changes required with the upgrade
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, UsingTransport<Msmq>
{
}
public class CustomInit : IWantCustomInitialization
{
public void Init()
{
Configure.Features.Enable<Sagas>();
Configure.Serialization.Xml();
Configure.Instance
.CastleWindsorBuilder()
.UseInMemoryTimeoutPersister()
.ConfigureMongoSagaPersister<CreateOrderSagaData>("mongodb://localhost/create-order");
Configure.Instance
.MsmqSubscriptionStorage()
.UnicastBus()
.CreateBus()
.Start();
}
}
When bootstrapping a different container, use the IWantCustomInitialization interface together with the IConfigureThisEndpoint like @JohnSimons mentioned.
Also, when you are implementing the IWantCustomInitialization in the IConfigureThisEndpoint, there is no bus yet, so an instance has not been created at this point, so you'd need to use Configure.With() instead of Configure.Instance.
NOTE: You don't need to specify UsingTransport as Msmq is the default transport. You also don't need to specify Configure.Serialization.Xml() as Xml is the default serializer.
So, if you change your code to something like below, it should work: