I'm using NServiceBus 3.3.3. I'm using Ninject as my container and I'm initialising the bus in an module by binding to the following method:
Bind<IBus>().ToMethod(context =>
{
return CreateBus();
}).InSingletonScope();
private IBus CreateBus()
{
var bus = NServiceBus.Configure.With()
.NinjectBuilder(this.Kernel)
.DefineEndpointName("MyEndpointName")
.MsmqTransport()
.IsTransactional(true)
.PurgeOnStartup(false)
.DisableRavenInstall()
.DisableTimeoutManager()
.InMemorySubscriptionStorage()
.XmlSerializer()
.UnicastBus()
.ImpersonateSender(false)
.CreateBus();
return bus.Start(() => Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());
}
The same code works fine in a different (MVC4) project but in my WCF WAS service I seems that the transport
member of UnicastBus
is always null and thus line 824 transport.MaxThroughputPerSecond = license.MaxThroughputPerSecond;
falls over.
Object reference not set to an instance of an object. at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start(Action startupAction) in c:\TeamCity\buildAgent\work\nsb.master_2\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 824 at Access.Cloud.WebService.Modules.NServiceBusModule.CreateBus() in l:\Projects\aCloud\InsightIntegration\Access.Cloud.WebService\Modules\NServiceBusModule.cs:line 47 at Access.Cloud.WebService.Modules.NServiceBusModule.b__0(IContext context) in l:\Projects\aCloud\InsightIntegration\Access.Cloud.WebService\Modules\NServiceBusModule.cs:line 25 at Ninject.Activation.Provider'1.Create(IContext context) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Provider.cs:line 38 at Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\ninject\src\Ninject\Activation\Context.cs:line 157 at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext()
I've checked it in the debugger too and sure enough transport
is null.
I'm guessing it's something environmental but I assume the transport just comes from some bindings that get set up when MsmqTransport()
is called. I tried moving the code that loads the module from the Ninject web bootstrapper to Global.asax but it didn't make a difference.
Any help or guidance appreciated!
DefaultBuilder()
is used. – mackie