Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find source of Exception shown in VS output window [duplicate]

When running my application in VS2013 I get the exceptions:

A first chance exception of type 'System.InvalidOperationException' occurred in mscorlib.dll

and

A first chance exception of type 'System.InvalidOperationException' occurred in mscorlib.dll

This exceptions are caught anywhere since my application does not crash, everything works "normal". But I would really like to find the code section causing this exceptions to solve this.

What can I do to find out which part of my code throws this exception or where it happens. Is there a way to show/visualize this in VS? Debugger options?

like image 241
ck84vi Avatar asked Dec 09 '15 06:12

ck84vi


1 Answers

What can I do to find out which part of my code throws this exception or where it happens. Is there a way to show/visualize this in VS? Debugger options?

In Visual Studio, choose Debug then Exceptions.

In the Exceptions window, tick Thrown on the Common Language Runtime Exceptions row.

enter image description here

Click OK.

Now whenever an exception is thrown, the debugger will break on the offending line. You can also expand the selection to only include the exceptions of interest.

Visual Studio 2017

You can find this under Debug.Windows.Exception Settings

enter image description here

enter image description here

like image 103
MickyD Avatar answered Sep 26 '22 13:09

MickyD