skb
skb

Reputation: 31084

NServiceBus: "ArgumentNullException" being thrown by 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?

Upvotes: 3

Views: 795

Answers (1)

skb
skb

Reputation: 31084

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.

Upvotes: 5

Related Questions