Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

How to Dump Data Causing FormatException?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
samueltilden@gmail.com - 25 Jun 2007 21:24 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.