Friday, April 15, 2011

Is there a place that outlines causes of generic .NET error messages?

The specific error that I'm getting is a System.ArgumentException with a message of "Value does not fall within the expected range".

I'd like to know specifically what could cause this error (I suspect some kind of overflow), but I'd also like to know if there's a place where these sort of generic .NET messages and their causes are listed.

From stackoverflow
  • You need to look at the stack trace - the combination of stack trace + message is usually enough to make the exception understandable.

    If it's a framework type throwing the exception, find the first public method call in the sdtack trace and look it up on MSDN. That should explain what the method expects and what else might cause exceptions.

  • Unfortunately, we would need more information to help.

    The Exception used, and the specific error message, are the responsibility of the library creator. This type of "very generic" exception message is unfortunately common in many poorly written libraries.

    Exception messages should be very specific, so it's obvious what caused the exception. In this case, since it's an ArgumentException, the stack trace should provide you with enough information to decipher which method is throwing the exception. A better message would make it obvious which argument was invalid, but that would be up to the author of the library to implement.

  • If you know the class and method (as shown by stack trace) then you should be able to use Reflector to figure out what went wrong (assuming the exception message doesn't tell you).

    To answer the later part of your question, you could use Reflector->F3->ArgumentException, double click result and hit Ctrl+R to analyse where is it used. That way you can specify the BCL (various versions) or whatever assembly you like (just has to be loaded in Reflector).

0 comments:

Post a Comment