random .NET and web development musings

When implementing custom exceptions in .NET, especially if you’re writing a library that others are going to use, always implement the deserialization constructor:

MyException (SerializationInfo info, StreamingContext context) : base(info, context)

Not doing so will cause others to hate you when your exceptions cause further SerializationExceptions.

just do it.

2 COMMENTS
Andrew Barber
April 15, 2012
ad

Oh yes, isn’t this the truth! Do devs forget their Exceptions are going to need to cross AppDomain boundaries?

April 15, 2012
ad

I think its probably ignorance, many don’t understand what its for so don’t implement it.

Post a comment