When designing custom exceptions for .NET, MSDN provides these guidelines. In particular, the guidelines state that a custom exception:
- should be serializable, i.e. implement
ISerializable
and be decorated with the[Serializable]
attribute, and - should implement the (de)serialization constructor, i.e.
protected CustomException(SerializationInfo info, StreamingContext context)
.
However, in a Portable Class Library neither of SerializableAttribute
, ISerializable
and SerializationInfo
are supported.
How should I sufficiently design a custom exception in a Portable Class Library that simultaneously targets .NET Framework and one or more platforms?