Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging TargetInvocationException

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.

enter image description here

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?

like image 750
Bryan Avatar asked Dec 08 '13 10:12

Bryan


People also ask

What does TargetInvocationException mean?

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.

How do I debug async method?

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.

What is system reflection TargetInvocationException?

System. Reflection. TargetInvocationException was unhandled Message=Exception has been thrown by the target of an invocation. Source=mscorlib StackTrace: at System.


1 Answers

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 -

enter image description here

enter image description here

like image 84
Rohit Vats Avatar answered Sep 21 '22 15:09

Rohit Vats