How to know which part of the code an exception happened by looking at Visual Studio Output

Asked

Viewed 147 times

2

I realized that in some requisitions the output of mine Visual Studio displays some messages such as this:

Exception generated: 'System.Collections.Generic.Keynotfoundexception' in mscorlib.dll

Generated exception: 'System.Nullreferenceexception' in Siteteste.dll

Follows the Printscreen of errors in output

inserir a descrição da imagem aqui

Some exceptions are displayed to class/line that the error happened, but looking at these I stay in the dark. How can I know in which part of the system these errors are happening?

  • 1

    There is an attribute in Exception called Stacktrace, it shows where the error occurred and its propagations

  • @Guilhermebarros but these exceptions are happening and the program is not stopping (as when an Exception happens), it skips the Exception knows? just log on the output and more nd...

  • 1

    Dude, in actions it’s interesting to cover the actions with Try catch and then capture the exceptions and, as you want to display Stacktrace of the exceptions on the console, you will use Console.Writeline(ex.Message) and Console.Writeline(ex.Stacktrace) and then throw again

1 answer

0

Opening the Exception Settings window (shortcut Ctrl+alt+e) takes a look at whether the exception in question is selected (has a search there that makes it easier), if it is not selected just select that when falling into the exception it to

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.