Skip to main content
All docs
V25.1
  • DeserializationSettings.DenyBinaryFormatter() Method

    Disables BinaryFormatter deserialization in the application to address BinaryFormatter Obsoletion Strategy.

    Namespace: DevExpress.Utils

    Assembly: DevExpress.Data.v25.1.dll

    NuGet Package: DevExpress.Data

    Declaration

    public static IDisposable DenyBinaryFormatter()

    Returns

    Type
    IDisposable

    Remarks

    Call the DenyBinaryFormatter method at application startup to disable BinaryFormatter deserialization:

    static void Main() {
        DevExpress.Utils.DeserializationSettings.DenyBinaryFormatter();
        Application.Run(new Form1());  
    }
    

    Use the InvokeWithBinaryFormatterDenied method to disable BinaryFormatter deserialization for a certain part of your code:

    DevExpress.Utils.DeserializationSettings.InvokeWithBinaryFormatterDenyed(()=>{  
        // BinaryFormatter is disabled.
    });
    

    Read the following topic for more information: Safe Deserialization.

    See Also