C# Abstract Exceptions

We’ve just been writing some new exceptions based initially on an abstract Exception class. When the attempt to write a catch statement to catch all exceptions which inherited from this abstract base class it wasn’t behaving as expected.

The gotcha here is that C#/.NET doesn’t allow you to catch exceptions from an abstract class. If you want to catch a base class Exception, avoid that abstract.

You have been warned! This is for .NET 2 by the way 🙂