Binary Formatter Serializer

Component: Binary Serializer
NuGet NServiceBus (5.x)
In Version 6 and above, the BinarySerializer was deprecated. Use one of the supported serializers, or an external serializer.

This sample uses the Binary Formatter serializer in the core.

Configuring to use Binary

var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Serialization.Binary");
busConfiguration.UseSerialization<BinarySerializer>();

The message send

var message = new CreateOrder
{
    OrderId = 9,
    Date = DateTime.Now,
    CustomerId = 12,
    OrderItems = new List<OrderItem>
    {
        new OrderItem
        {
            ItemId = 6,
            Quantity = 2
        },
        new OrderItem
        {
            ItemId = 5,
            Quantity = 4
        },
    }
};
bus.SendLocal(message);

Related Articles


Last modified