本文介绍了NServiceBus 找不到映射到 XXX 错误的具体类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试发布一个定义为接口的事件:
I am trying to publish an event which is defined as an interface:
Bus.Publish<IAccountCreated>(m => { m.Key = Guid.NewGuid(); });使用 JSON 序列化程序时,它给了我错误:
When using the JSON serializer, it gives me the error:
找不到映射到 Contracts.IAccountCreated 的具体类型
Could not find a concrete type mapped to Contracts.IAccountCreated
它与 XML 序列化程序配合得很好.
It works fine with the XML serializer.
我的端点配置:
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"))我使用的是 NServiceBus 3.3.3.
I'm using NServiceBus 3.3.3.
推荐答案事实证明,您在流畅的界面中执行操作的顺序很重要.
It turns out that the order you do things in the fluent interface is important.
这有效:
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更多推荐
NServiceBus 找不到映射到 XXX 错误的具体类型
发布评论