NServiceBus:“ArgumentNullException”被 NServiceBus 抛出
我试图调用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了答案。显然,在 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.