When designing custom exceptions for .NET, MSDN provides these guidelines. In particular, the guidelines state that a custom exception:
ISerializable
and be decorated with the [Serializable]
attribute, andprotected 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?
Basically, ignore that guidance - that is for full .NET, and does not apply to portable class library projects. Indeed, if we look at (say) Silverlight (which includes WP7) we see:
[ClassInterfaceAttribute(ClassInterfaceType.None)]
[ComVisibleAttribute(true)]
public class Exception
Frankly, the main consumer of that requirement was remoting... and that is not in huge demand now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With