NServiceBus 找不到映射到 XXX 错误的具体类型 [英] NServiceBus Could not find a concrete type mapped to XXX error

查看:55
本文介绍了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 错误的具体类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆