You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This case is now explicitly detected and a better exception is thrown.
So this
Configure.Serialization.Json();
var bus = Configure.With()
.DefaultBuilder()
.UseTransport<Msmq>()
.InMemorySagaPersister()
.UnicastBus()
.CreateBus()
.Start(() => Configure.Instance.ForInstallationOn<Windows>().Install());
bus.Send(new MyMessage());
Console.ReadLine();
With no mapping configured for MyMessage
Will result in a NullReferenceException with the following stack trace
at NServiceBus.Transports.Msmq.MsmqUtilities.GetFullPath(Address value) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Transports\Msmq\MsmqUtilities.cs:line 27
at NServiceBus.Transports.Msmq.MsmqMessageSender.Send(TransportMessage message, Address address) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Transports\Msmq\MsmqMessageSender.cs:line 38
at NServiceBus.Unicast.Behaviors.DispatchMessageToTransportBehavior.Invoke(SendPhysicalMessageContext context, Action next) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Behaviors\DispatchMessageToTransportBehavior.cs:line 76
at NServiceBus.Pipeline.BehaviorChain`1.InvokeNext(T context) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 28
at NServiceBus.Pipeline.BehaviorChain`1.<>c__DisplayClass1.<InvokeNext>b__0() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 28
at NServiceBus.MessageMutator.MutateOutgoingPhysicalMessageBehavior.Invoke(SendPhysicalMessageContext context, Action next) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\MessageMutator\MutateOutgoingPhysicalMessageBehavior.cs:line 19
at NServiceBus.Pipeline.BehaviorChain`1.InvokeNext(T context) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 28
at NServiceBus.Pipeline.BehaviorChain`1.<>c__DisplayClass1.<InvokeNext>b__0() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 28
at NServiceBus.Unicast.Behaviors.SerializeMessagesBehavior.Invoke(SendPhysicalMessageContext context, Action next) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Behaviors\SerializeMessagesBehavior.cs:line 40
at NServiceBus.Pipeline.BehaviorChain`1.InvokeNext(T context) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 28
at NServiceBus.Pipeline.BehaviorChain`1.Invoke(T context) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 15
at NServiceBus.Pipeline.PipelineFactory.Execute[T](BehaviorChain`1 pipelineAction, T context) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\PipelineFactory.cs:line 166
at NServiceBus.Pipeline.PipelineFactory.InvokeSendPipeline(SendOptions sendOptions, TransportMessage physicalMessage) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\PipelineFactory.cs:line 130
at NServiceBus.Unicast.Behaviors.CreatePhysicalMessageBehavior.Invoke(SendLogicalMessagesContext context, Action next) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Behaviors\CreatePhysicalMessageBehavior.cs:line 52
at NServiceBus.Pipeline.BehaviorChain`1.InvokeNext(T context) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 28
at NServiceBus.Pipeline.BehaviorChain`1.<>c__DisplayClass1.<InvokeNext>b__0() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 28
at NServiceBus.Unicast.Behaviors.MultiMessageBehavior.Invoke(SendLogicalMessagesContext context, Action next) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Behaviors\MultiMessageBehavior.cs:line 19
at NServiceBus.Pipeline.BehaviorChain`1.InvokeNext(T context) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 28
at NServiceBus.Pipeline.BehaviorChain`1.<>c__DisplayClass1.<InvokeNext>b__0() in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 28
at NServiceBus.Unicast.Behaviors.MultiSendValidatorBehavior.Invoke(SendLogicalMessagesContext context, Action next) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\Behaviors\MultiSendValidatorBehavior.cs:line 33
at NServiceBus.Pipeline.BehaviorChain`1.InvokeNext(T context) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 28
at NServiceBus.Pipeline.BehaviorChain`1.Invoke(T context) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 15
at NServiceBus.Pipeline.PipelineFactory.Execute[T](BehaviorChain`1 pipelineAction, T context) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\PipelineFactory.cs:line 166
at NServiceBus.Pipeline.PipelineFactory.InvokeSendPipeline(SendOptions sendOptions, IEnumerable`1 messages) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Pipeline\PipelineFactory.cs:line 97
at NServiceBus.Unicast.UnicastBus.InvokeSendPipeline(SendOptions sendOptions, List`1 messages) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 728
at NServiceBus.Unicast.UnicastBus.SendMessages(SendOptions sendOptions, List`1 messages) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 704
at NServiceBus.Unicast.UnicastBus.Send(Object[] messages) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 550
at NServiceBus.Unicast.UnicastBus.Send(Object message) in y:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 534
We should give a better exception
The text was updated successfully, but these errors were encountered:
System.InvalidOperationException: No destination specified for message(s): MyClient.Foo
at NServiceBus.Unicast.UnicastBus.<>c__DisplayClass16.<SendMessage>b__11(Addr
ess address) in c:\TeamCity\buildAgent\work\nsb.master_0\src\unicast\NServiceBus
.Unicast\UnicastBus.cs:line 715
at System.Collections.Generic.List`1.ForEach(Action`1 action)
...
Note that this is not a real test. just a helper to reproduce and verify the fix
public class FakeTest : NServiceBusAcceptanceTest
{
[Test]
public void Should_receive_the_message()
{
Scenario.Define(() => new Context())
.WithEndpoint<Sender>(b => b.Given((bus, context) => bus.Send(new MyMessage())))
.WithEndpoint<Receiver>()
.Done(c => c.WasCalled)
.Run();
}
public class Context : ScenarioContext
{
public bool WasCalled { get; set; }
}
public class Sender : EndpointConfigurationBuilder
{
public Sender()
{
EndpointSetup<DefaultServer>()
// uncomment this line and it works
//.AddMapping<MyMessage>(typeof(Receiver))
;
}
}
public class Receiver : EndpointConfigurationBuilder
{
public Receiver()
{
EndpointSetup<DefaultServer>();
}
}
public class MyMessage : ICommand
{
public Guid Id { get; set; }
}
public class MyMessageHandler : IHandleMessages<MyMessage>
{
public Context Context { get; set; }
public IBus Bus { get; set; }
public void Handle(MyMessage message)
{
Context.WasCalled = true;
}
}
}
This case is now explicitly detected and a better exception is thrown.
So this
With no mapping configured for
MyMessage
Will result in a
NullReferenceException
with the following stack traceWe should give a better exception
The text was updated successfully, but these errors were encountered: