NServiceBus找不到映射到XXX错误的具体类型

NServiceBus找不到映射到XXX错误的具体类型,nservicebus,Nservicebus,我正在尝试发布定义为接口的事件: Bus.Publish<IAccountCreated>(m => { m.Key = Guid.NewGuid(); }); Bus.Publish(m=>{m.Key=Guid.NewGuid();}); 使用JSON序列化程序时,会出现以下错误: 找不到映射到Contracts.IAccountCreated的具体类型 它可以与XML序列化程序配合使用 我的端点配置: Configure.With() .DefaultBuil

我正在尝试发布定义为接口的事件:

Bus.Publish<IAccountCreated>(m => { m.Key = Guid.NewGuid(); });
Bus.Publish(m=>{m.Key=Guid.NewGuid();});
使用JSON序列化程序时,会出现以下错误:

找不到映射到Contracts.IAccountCreated的具体类型

它可以与XML序列化程序配合使用

我的端点配置:

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"))
Configure.With()
.DefaultBuilder()
.JsonSerializer()t.命名空间!=null&&t.Namespace.StartsWith(“网站”))
.DefiningEventsAs(t=>t.Namespace!=null&&t.Namespace.Contains(“合同”))

我使用的是NServiceBus 3.3.3。

事实证明,在fluent界面中执行操作的顺序很重要

这项工作:

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
Configure.With()
.DefaultBuilder()
.DefiningCommandsAs(t=>t.Namespace!=null&&t.Namespace.StartsWith(“网站”))
.DefiningEventsAs(t=>t.Namespace!=null&&t.Namespace.Contains(“合同”))

.JsonSerializer()将您的约定移动到With()之后,看看这是否有帮助。谢谢Andreas,这很有效。这会在某个时候被“修复”吗?流畅的接口不应该是顺序无关的吗?谢谢我们一定会修好的。但它不会进入4.0版本