Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unhandled Exception in EXE but not in IDE.

Status
Not open for further replies.

RichLee

Programmer
May 2, 2001
49
GB
I have a VB .net application which raises an 'Unhandled Exception' when running as an exe. In the IDE the correct top-level error message is shown.

I have recreated the problem -


In module1.vb -

Code:
Sub Main
    Try
        Application.Run(New Form1)
    Catch ex As Exception
        MessageBox.Show("FATAL ERROR in Application")
    End Try
End Sub


Form1 has a single Button Control
Code in Form1.vb -

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Try
        Throw New Exception("Thrown Error!")
    Catch ex As Exception
        Throw New Exception("B1_Click error")
    End Try
End Sub


So, when the button is clicked, a message box should be displayed with the text 'FATAL ERROR in Application'. This works fine when running within the .Net IDE. However, when running the .exe - on the development PC or on another PC - a box is displayed saying that there was an unhandled exception. The exception which is unhandled is 'B1_Click error'.

Has anyone else seen this behaviour and how do I fix it?
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Throw New Exception("Thrown Error!")
Catch ex As Exception
Try
Throw New Exception("B1_Click error")
Catch ex As Exception
Msgbox("B1_Click error")
End Try
End Try
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top