NServiceBus:“ArgumentNullException”被 NServiceBus 抛出

发布于 2024-10-07 14:16:53 字数 964 浏览 1 评论 0原文

我试图调用 Bus.Publish 来发布消息,但我不知道出了什么问题,因为 NSB 的异常只是有一个空参数。

这是堆栈跟踪:

System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at NServiceBus.Serializers.XML.MessageSerializer.WriteObject(String name, Type type, Object value, StringBuilder builder)
   at NServiceBus.Serializers.XML.MessageSerializer.Serialize(IMessage[] messages, Stream stream)
   at NServiceBus.Unicast.Transport.Msmq.MsmqTransport.Send(TransportMessage m, String destination)
   at NServiceBus.Unicast.UnicastBus.SendMessage(IEnumerable`1 destinations, String correlationId, MessageIntentEnum messageIntent, IMessage[] messages)
   at NServiceBus.Unicast.UnicastBus.Publish[T](T[] messages)

有人可以帮忙吗?

I am trying to call Bus.Publish to publish a message, but I can't tell what's wrong, because the exception from NSB is just that there is a null argument.

Here is the stack trace:

System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at NServiceBus.Serializers.XML.MessageSerializer.WriteObject(String name, Type type, Object value, StringBuilder builder)
   at NServiceBus.Serializers.XML.MessageSerializer.Serialize(IMessage[] messages, Stream stream)
   at NServiceBus.Unicast.Transport.Msmq.MsmqTransport.Send(TransportMessage m, String destination)
   at NServiceBus.Unicast.UnicastBus.SendMessage(IEnumerable`1 destinations, String correlationId, MessageIntentEnum messageIntent, IMessage[] messages)
   at NServiceBus.Unicast.UnicastBus.Publish[T](T[] messages)

Can anyone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

再可℃爱ぅ一点好了 2024-10-14 14:16:53

找到了答案。显然,在 NServiceBus 中使用未在命名空间中声明的消息类型是非法的。不要问我为什么,但是包含我想要发布的类型的遗留代码没有在命名空间中声明该类型,因此我必须创建一个新类型才能使其工作。

Found the answer. Apparently it is illegal in NServiceBus to use a message type which is not declared in a namespace. Don't ask me why, but the legacy code containing the type I wanted to publish didn't declare the type in a namespace so I had to make a new type to get it to work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文