Visual Studio does not throw exceptions on Form_Load event
I recently upgraded my laptop with Vista 32bit using Visual Studio 2005/2008 installed on Windows 7 x64 with only Visual Studio 2008 installed. So I don't know if this is a "Windows 7" issue or just a configuration in visual studio.
My problem is that the exceptions in the Form_Load () event get swallowed without warning, making it difficult to debug the errors because sometimes I don't even notice that an exception is happening.
Let's say I have this code (Code is VB.NET, but C # style comment because syntax marker doesn't recognize "as comment")
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
// Outside the Debugger the exception triggers the default
// "Unhandled Exception" Dialog which is correct.
// Withing 2008 IDE the debugger doen not break like it
// should. However the exception still occures because
// this text is printed to the Output Window:
// A first chance exception of type 'System.Exception'
// occurred in ExceptionTest.exe
Throw New Exception("This Exception gets swallowed")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
// This exception causes the Debugger to break at this line
Throw New Exception("This Exception works fine")
End Sub
End Class
I found a suggestion to check the "dropped" checkbox in the Exceptions dialog ("CTRL + D, E"). If I do this, the debugger breaks on the Form_Load () exception as I want it, but it also breaks on every exception handled, like this:
Try
DoSmthThatThrowsArgumentException() // Debugger breaks here
Catch ex as ArgumentException
LogWriter.Write(ex.ToString())
End Try
Does anyone have a clou how to set up the VS2008 Debugger to behave correctly in the Form_Load () event? According to this post , it looks like it came up unexpectedly with visual studio 2008.
source to share
No one has answered this question yet
See similar questions:
or similar: