1

When running a VB.NET Winforms application in Visual Studio 2015 (debug mode), Immediate Window shows notice about handled exceptions this way (it is in Portuguese but I think English is not so different):

Exceção gerada: 'System.NullReferenceException' em MyApp.exe
Exceção gerada: 'System.NullReferenceException' em MyApp.exe
Exceção gerada: 'System.NullReferenceException' em MyApp.exe
Exceção gerada: 'System.NullReferenceException' em MyApp.exe
Exceção gerada: 'System.NullReferenceException' em MyApp.exe
Exceção gerada: 'System.NullReferenceException' em MyApp.exe

My question is: can I adjust some setting so that it shows also where it comes from? (filename and line number, or method name, or both if possible)

Thank you very much.

VBobCat
  • 2,527
  • 4
  • 29
  • 56

1 Answers1

1

I cant promise this is a fix because my portugese is limited, but there is a window called Exception Settings that you can usually bring up with CTRL+ALT+E, where you have checkboxes for all types of exception and if your code should break when they happen.

Find the one called NullReferenceException for example and make sure it's checked and your code should break when the exceptions are thrown (gerada?).

If you have problems finding the Exception Settings window check top answer on this post:

Visual Studio 2015 break on unhandled exceptions not working

Community
  • 1
  • 1
taracus
  • 393
  • 1
  • 5
  • 19
  • Thanks, your translation is right ("gerada"=generated, but that's the same idea), and your solution works fine. Instead of breaking, however, is there some way Immediate Window logs can be made richer in order to be analysed in post-running? Thank you very much! – VBobCat Dec 07 '16 at 13:02
  • 1
    Im not sure that is possible, you can redirect all your output information to the Immediate Window through the menu: Tools -> Options -> Debugging -> Redirect all Out Window text to the Immediate Window, but Im not sure that will give you more information. Perhaps if you look around under the Debugging options you'll find something more suitable. – taracus Dec 07 '16 at 13:13
  • @ VBobCat, to capture the exception message, I also suggest you use the Exception settings window which could throw the Exception messages in the specific line code. So I agree with taracus' suggestion, you would debug it in your side after you capture this exception in specific line code. If taracus' reply is helpful for you, please mark it as the answer. Have a nice day. – Jack Zhai Dec 16 '16 at 11:33