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

编程入门 行业动态 更新时间:2024-10-26 16:29:36
本文介绍了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 错误的具体类型

本文发布于:2023-11-04 10:25:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557674.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   错误   类型   NServiceBus   XXX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!