Table of Contents

Serialization Overview

Objects in your client application must be serialized to a stream prior to storage in the ScaleOut service. Use the CacheBuilder.SetSerialization method to configure serialization callbacks for your cache. A CacheBuilder.UseJsonSerialization convenience method is also provided for JSON serialization of simple C# classes ("POCOs").

Default Serialization

If a serializer is not configured with the CacheBuilder, the cache will fall back to default serialization implementations for primitive types such as strings, integers, floats, bools, and Guids. These primitives will have their binary representations stored directly in the service (strings will be serialized as UTF-8 encoded byte arrays).

Complex types must have a serializer specified in NET 5+ applications, otherwise the CacheBuilder will throw an InvalidOperationException when its Build() method is called. Use the CacheBuilder.SetSerialization or CacheBuilder.UseJsonSerialization method to configure serialization for your cache.

Important

In .NET Framework 4.x applications, the Cache will fall back to using the BinaryFormatter for complex types if a serializer is not explicitly specified. This is done for backwards compatibility, but application authors should migrate away from the BinaryFormatter as soon as possible. The BinaryFormatter has been officially deprecated in modern versions of .NET, and its performance is poor compared to modern serializers such as protobuf-net or MessagePack. Also, its flexibility has given rise to security vulnerabilities in some application contexts.

The Scaleout.Client library does not deserialize untrusted input, so the security threat from the library's default BinaryFormatter usage is minimal. However, developers are encouraged to follow Microsoft's guidance and use a safe, modern serializer early in their development projects.