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 live online training, plus books, videos, and digital content from nearly 200 publishers.