Difference in behavior from XML to JSON serializer

Hello, to address the startup warning regarding no explicit serializer set, we decided to set the default serializer to JSON. This lead to a deserialization failure. We reverted to XML.

The message that failed has a property of type System.Exception. The message was sent with a custom subclass. This resulted in the error “An error occurred while attempting to extract logical messages from incoming physical message”. The specific message is “Message: Member ‘HelpURL’ was not found.”

Some Googling suggests the problem is within the NewtonSoft JSON deserializer. While I think this is probably a bad design, to declare a base class as a type, the fact is it works as expected (yields a deserialized Exception, not the actual subclass type) with XML as the serializer.

As said, we reverted to XML. We expect to use JSON as a supplemental deserializer for native SQS support only. We don’t have a blocking condition here, but just provide this description of our experience should you wish to pursue a bug fix.

Hi, Daryl.

Thank you for reaching out to us about the issue that you are experiencing.

NServiceBus serializers are thin wrappers around serialization libraries. This is intentional on our part as it minimizes the likelihood of unexpected behavior that developers might not be aware of. In some cases, the specific implementation details of a serializer may result in different behavior between serialization libraries.

In your case, it appears that what you are experiencing may be related to this Newtonsoft issue. The replies include some suggestions for resolving this issue.

NServiceBus provides the ability to configure the serialization library that you are using in order to address these sorts of edge cases.