I added NSB v7.3 to ASP.NET Web API’s IHostedService, because I wanted to receive commands and events and have REST api at the same project.
IHostedService starts working, I add timer to call a method “DoWork” each 5 seconds, each time the method is called, when I try to use the
IMessageSession to publish an event, it throws an exception:
System.AggregateException: One or more errors occurred. (Value cannot be null. (Parameter ‘session’)) —> System.ArgumentNullException: Value cannot be null. (Parameter ‘session’) at NServiceBus.Guard.AgainstNull(String argumentName, Object value) at NServiceBus.IMessageSessionExtensions.Publish(IMessageSession session, Object message)…
Any idea what’s the cause?
I’m using the same idea else where, but I was sure the API service will be receiving a request to one of its
Controller before the
Publish was called (maybe it’s causing to initiate a session before it’s being used by the
In this new API I’m not sure that a
Controller will be called first.