I have an endpoint, called UploadService, that contains a saga started by a command defined in another assembly. The commands in that assembly are registered in the endpoint's initialization via the following lines:
public class EndpointInitialization : IWantCustomInitialization
{
public void Init()
{
NServiceBus.Configure.Features.Enable<NServiceBus.Features.Sagas>();
NServiceBus.Configure.With()
.Log4Net()
.UseInMemoryTimeoutPersister()
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith("Commands"))
.DefiningMessagesAs(t => t.Namespace != null && t.Namespace.Contains("Messages"))
.UnicastBus()
.ImpersonateSender(false)
.CreateBus()
.Start();
}
}
However, when start the endpoint via Debug->Start new instance, NServiceBus.Core throws the following exception:
"The saga 'MySaga' implements 'IHandleMessages`1' but the message type 'MyCommand' is not classified as a message. You should either use 'Unobtrusive Mode Messages' or the message should implement either 'IMessage', 'IEvent' or 'ICommand'."
I have a seprate endpoint which references the same Commands assembly, and has custom initialization defined the same way, and starts up just fine (only difference is the other endpoint does not use sagas).
UPDATE: I'm using NServiceBus 4.2