NServiceBus Could not find a concrete type mapped to XXX error

孤街浪徒 提交于 2020-01-15 11:47:06

问题


I am trying to publish an event which is defined as an interface:

Bus.Publish<IAccountCreated>(m => { m.Key = Guid.NewGuid(); });

When using the JSON serializer, it gives me the error:

Could not find a concrete type mapped to Contracts.IAccountCreated

It works fine with the XML serializer.

My endpoint configuration:

Configure.With()
    .DefaultBuilder()
    .JsonSerializer() <-- when this is here I get the error.
    .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("Website"))
    .DefiningEventsAs(t => t.Namespace != null && t.Namespace.Contains("Contracts"))

I'm using NServiceBus 3.3.3.


回答1:


It turns out that the order you do things in the fluent interface is important.

This works:

Configure.With()
    .DefaultBuilder()
    .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("Website"))
    .DefiningEventsAs(t => t.Namespace != null && t.Namespace.Contains("Contracts"))
    .JsonSerializer() <-- moving this down works


来源:https://stackoverflow.com/questions/14124428/nservicebus-could-not-find-a-concrete-type-mapped-to-xxx-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!