When I catch a System.FormatException, the most information it gives
me is:
"The string was not recognized as a valid DateTime."
What is "the string" (i.e., its value)?
How can I find out, programmatically within the catch block, what the
actual value of the string is?
P.S. I've tried to dump out the MethodBase TargetSite of the exception
but did not (yet) find the data causing the exception.
Thanks.
samueltilden@gmail.com - 25 Jun 2007 21:38 GMT
One additional piece of information:
When I do dump out the MethodBase TargetSite, I can get the input
parameters of the Parse() function, especially the first paremeter,
"string s". I tried to get the actual value of the parameter "s"
passed into this Parse() function, but have not yet been successful.
Do you think that this approach will eventually yield the value of the
bad data, or is there some totally different approach?
Thanks.
Nicholas Paldino [.NET/C# MVP] - 25 Jun 2007 21:50 GMT
No, it won't, as the MethodInfo (and ParameterInfo instances) only tell
you about the structure of the method, they don't actually have access to
any of the data of the method when it is running (since any thread at any
time can run the method, how would you be able to get it from a single entry
point?).

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> One additional piece of information:
>
[quoted text clipped - 7 lines]
>
> Thanks.
Nicholas Paldino [.NET/C# MVP] - 25 Jun 2007 21:46 GMT
There really isn't any way to do that. You have to be aware of where
the exception was thrown, and the string that was passed to whatever method
threw it.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> When I catch a System.FormatException, the most information it gives
> me is:
[quoted text clipped - 10 lines]
>
> Thanks.