Optionally, the OptionalField property has been disabled in C #?

It seems that OptionalFieldAttribute is no longer required (if ever) to serialize with BinaryFormatter.

When using the example from codeguru, there is no longer any exception when creating code in Visual Studio 2010, even if it is intended for earlier versions of the .NET framework.

Another question about stackoverflow suggests that it has always been optional. It's true? And if so, is there really no way to get an exception for a missing field when serialized to binary content in .NET?

+2
source share
1 answer

To get an exception, add this statement to the deserialization code:

formatter.AssemblyFormat = FormatterAssemblyStyle.Full; 
+6
source

Source: https://habr.com/ru/post/1433761/


All Articles