Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NServiceBus: "ArgumentNullException" being thrown by NServiceBus

Tags:

nservicebus

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?

like image 310
skb Avatar asked Nov 20 '25 20:11

skb


1 Answers

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.

like image 104
skb Avatar answered Nov 24 '25 14:11

skb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!