Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Serialization Changes in NServiceBus Version 6

Component: NServiceBus

This is part of the NServiceBus Upgrade Guide from Version 5 to 6, which also includes the following individual upgrade guides for specific components:

Feature Details
Transports
Persistence
Hosting
Other

BinarySerializer deprecated

The BinarySerializer is deprecated. Use one of the supported serializers or an external serializer.

No dependency injection for IMessageSerializer

The IMessageSerializer instances are now produced by a factory (as described in this article) instead of being resolved through dependency injection.

Built-in serializers are internal

Built-in JSON and XML serializers are internal starting with NServiceBus version 6. If a custom serializer depends on one of these serializers, the code will need to be copied.

Standardized XML Serialization

Handling of null types within the XML serializer now conforms to the W3C Specification by using the xsi:nil="true" attribute.

This change is backward compatible and will have no impact on communication between older versions of endpoints and newer versions. Older versions will be able to communicate with newer versions and vice versa.

Given the following class:

public class MessageWithNullable : IMessage
{
    public string FirstName { get; set; }
    public DateTime? BirthDate { get; set; } //Nullable DateTime property
}

A null BirthDate would result in a message in the following:

// For NServiceBus version 6.x
<MessageWithNullable 
  xmlns="http://tempuri.net/NServiceBus.Serializers.XML.Test">
  <FirstName>FirstName</FirstName>
  <BirthDate xsi:nil="true"></BirthDate>
</MessageWithNullable>

// For NServiceBus version 5.x
<MessageWithNullable 
  xmlns="http://tempuri.net/NServiceBus.Serializers.XML.Test">
  <FirstName>FirstName</FirstName>
  <BirthDate>null</BirthDate>
</MessageWithNullable>
External integration systems need to ensure compatibility when receiving messages in the new format.

BSON serializer deprecated

The BSON serializer built into the core has been removed. Use the Newtonsoft serializer as a replacement. Also see the Newtonsoft BSON sample.


Last modified