Sunday, September 10, 2006


.NET Exception Handling Guidelines: Custom Exceptions (part 3)

  • Derive custom exceptions from System.Exception or one of the other base exception types (but not System.ApplicationException).
  • Suffix custom exception type names with “Exception”
  • Make exceptions serialisable, so they can cross remoting and application domain boundaries.
  • Provide the following constructors on all custom exceptions, and use the same parameter names and types:


public class CustomException : Exception, ISerializable


public CustomException(){}

public CustomException(string message) { }

public CustomException(string message, Exception inner) { }

// This is required for serialisation

protected CustomException(SerializationInfo info, StreamingContext context) { }


part 1, part 2, and part 4 are here.


Powered by Blogger