Exception constructors

If you implement you own constructors, there are three constructors you should implement

public class MyException: Exception
{
    public MyException()
    { }

The first is the default and is required if you XmlSerialise your message

    public MyException(String message, Exception inner)
        : base(message, inner)
    { }

The second is the classic way of chaining exceptions together by providing an inner exception

    public MyException(SerializationInfo info, StreamingContext context)
        :
base(info, context)
    { }

And finally if you Serialise your error (e.g. across processes, COM+ etc) you need to provide this variant.

Add comment

  Country flag


  • Comment
  • Preview
Loading