Some Exceptions Worthy of Further Mention

Most exceptions are self-describing. For example, it is apparent in an ObjectDisposedException that your code attempted to use an object that has already been disposed of. Other exceptions that are self-explanatory include InvalidArgumentException, InvalidCastException, and NullReferenceException.

Whenever you catch an exception whose type and message are not enough to fully describe the problem, always check whether it exposes any custom properties that can help. A nonexhaustive list of examples of such exceptions includes WebException, SocketException, and SqlCeException. After these three, another set of four exceptions deserve special mention: InvalidOperationException, MissingMethodException, System.Resources. ...

Get Microsoft® Mobile Development Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.