I'm using Visual Studio 2008 (C# Express Edition) and I'm trying to debug a TargetInvocationException that occurs as a result of an event that I trigger.
My question isn't specificly about this exception, (hence why I've not included any detail about this exception), but more about using the IDE effectively to debug this.
I can see the inner exception gives me the detail I need to debug the error (clicking on 'View Detail' in the exception helper), but being fairly lazy, or should I say, trying to make good use of the tools I have at my disposal, I'd like to be able to convince the IDE to show me the exception helper for original (Inner Exception) within my code for the correct thread, complete with stack trace, rather than showing me the exception details for the calling thread.
Is this possible, and if so, how do I go about doing this?
TargetInvocationException uses the HRESULT COR_E_TARGETINVOCATION which has the value 0x80131604. When created, the TargetInvocationException is passed a reference to the exception thrown by the method invoked through reflection. The InnerException property holds the underlying exception.
Double-clicking an active or awaiting task shows the async call stack in the Call Stack window. To understand which thread is running a specific task, you can swap between the Parallel Threads and Parallel Tasks windows. You can do this by right-clicking and selecting Go To Thread in the context menu.
System. Reflection. TargetInvocationException was unhandled Message=Exception has been thrown by the target of an invocation. Source=mscorlib StackTrace: at System.
You can tell debugger to break on CLR exception
so that you can see the exact place where it is throwing exception.
You can check it under Debug -> Exceptions
.
You can find it here -
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With