NServiceBus: "ArgumentNullException" is thrown by NServiceBus

I am trying to call Bus.Publish to post a message, but I cannot say what is wrong because the exception from the NSB is just 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?

+3
source share
1 answer

Found the answer. It seems that NServiceBus does not allow the use of a message type that is not declared in the namespace. Don’t ask me why, but the old code containing the type I wanted to publish did not declare the type in the namespace, so I had to create a new type to make it work.

+5
source

Source: https://habr.com/ru/post/1780117/


All Articles