Page 1 of 1

Exception has been thrown by the target of an invocation...

Posted: Mon Jul 31, 2006 6:24 pm
by SirWinner
Yet another .Net error that doesn't say much.

In a \"Try...End Try\" block was attempting to catch the error in VB.Net:

Try
...Some Code...
Catch ex as exception
msgbox (ex.message.tostring)
End Try

- This link helped track it down:
http://www.geekpedia.com/Question70_Exc ... ation.html

Replaced the msgbox line with:

MessageBox.Show(ex.InnerException.Message)

The \"New Message\" revealed the routine that called the routine where the error was and the line in that routine where the error occurred.

Fixed the Offending Routine (Log File Routine) by encapulating it in a \"Try...End Try\" block.

Enjoy!

:)

Posted: Mon Jul 31, 2006 6:35 pm
by Topher
Even better, can't you use Visual Studio, Debug -> Exceptions and break anytime an exception is thrown? This should give you the exact location of where the exception is coming from.

Posted: Fri Aug 04, 2006 6:52 pm
by SirWinner
I'll try that next time... Thanks Topher!

;)

Posted: Fri Aug 04, 2006 10:09 pm
by DCrazy
Doesn't the Locals window put the $exception on the stack so you can walk through it when your program breaks? Even less clicking :)