Skip to content

Removal of BinaryFormatter in .NET 8.0 #1779

@MullerWasHere

Description

@MullerWasHere

Description

Due to security issues, BinaryFormatter will be removed in .NET 8.0 and its Serialize and Deserialize methods are currently obsolete in .NET 5.0.

There is currently a single use of BinaryFormatter's Serialize and Deserialize methods:

private static object CreateCloneUsingBinarySerializer(object subject)
{
using var stream = new MemoryStream();
var binaryFormatter = new BinaryFormatter
{
Binder = new SimpleBinder(subject.GetType())
};
binaryFormatter.Serialize(stream, subject);
stream.Position = 0;
return binaryFormatter.Deserialize(stream);
}

Although it's a long way off until BinaryFormatter is removed, I figured it'd be a good idea to bring some attention to it. I stumbled upon this while working on #1754.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions