Enables serialization of custom exception data in security-transparent code.

See Also: ISafeSerializationData Members


public interface ISafeSerializationData


In versions previous to.NET Framework 4.0, serialization of custom user data in a security transparent code was accomplished using the Exception.GetObjectData method. Starting with .NET Framework 4.0, that method is marked with the System.Security.SecurityCriticalAttribute attribute which prevents execution in security-transparent code. To work around this condition, implement the System.Runtime.Serialization.ISafeSerializationData interface and add custom data as shown in the example below.

The ISafeSerializationData.CompleteDeserialization method is called after serialization, and uses the System.Runtime.Serialization.SafeSerializationEventArgs to restore the custom data.


Namespace: System.Runtime.Serialization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: