0
votes

I am trying to integrate S#arp Architecture with NServicebus but I am getting some errors.

Anyone already used both projects together? Any examples about that?

The Ibus seems to be correctly instantiated but I am getting this error when I call the bus.Send(message).

System.NullReferenceException: Object reference not set to an instance of an object.

at NServiceBus.Unicast.MessageContext..ctor(TransportMessage transportMessage) in d:\BuildAgent-03\work\672d81652eaca4e1\src\unicast\NServiceBus.Unicast\MessageContext.cs: line 21 at NServiceBus.Unicast.UnicastBus.NServiceBus.IBus.get_CurrentMessageContext() in d:\BuildAgent-03\work\672d81652eaca4e1\src\unicast\NServiceBus.Unicast\UnicastBus.cs: line 787

2

2 Answers

2
votes

Another thing that it might be is that you're using RegisterWebCallback from your controller without passing in the page as an explicit parameter. NServiceBus tries to cast the target of the callback function to System.Web.Page and it could be that that is what becomes null (this has been captured as an explicit exception in more recent builds of version 2.0).

Hope that helps.

1
votes

By itself, Bus.Send(message) doesn't access Bus.CurrentMessageContext, which appears to be what is causing your problem. Try removing the call to Bus.CurrentMessageContext from your code and see if that solves your problem.