Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7972727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:56:26+00:00 2026-06-04T07:56:26+00:00

I have a VB.Net WinForms application that throws an exception when the application exits.

  • 0

I have a VB.Net WinForms application that throws an exception when the application exits. The exception only occurs on closing the application and in no way affects the functioning of the application. The exception thrown is InvalidOperationException and the debugger is not able to identify where the exception is occurring, rather in Visual Studio 2008 the exception is shown in a popup window without referencing a line number.

Here is someone else that has exactly the same issue:
http://bytes.com/topic/c-sharp/answers/659366-invalidoperationexception-appeared-after-introduction-webbrowser-control

As mentioned in this link, the exception is intermittant, but is somehow related to the WebBrowser control, because the exception on exiting the application only occurs when at least 2 forms with WebBrowser controls on them have been shown. (Or one form with a WebBrowser control opened and closed twice.)

Now in VB.Net I am able to catch the exception in the AppDomain.CurrentDomain.UnhandledException handler, but the only way I have managed to stop Windows from reporting the exception is to use MessageBox to show a message in the handler. If I leave off the MessageBox.Show call in the handler then the exception is reported when the application closes.

Does anyone know a way that I can suppress this exception in the UnhandledException handler so that the application will always exit cleanly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:56:28+00:00Added an answer on June 4, 2026 at 7:56 am

    I found the answer to my question one of the responses to this question:

    How to use ThreadException?

    Add this to the UnhandledException method to prevent the Windows crash notification from showing up:

    Environment.Exit(1)

    Thanks Hans Passant for this useful information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .net WinForms 2.0 application that has an image library of about
I have a WinForms application written in C# for .NET 3.5 that needs to
I'm developing a .NET application that will have both a WinForms and a Silverlight
I have a .NET WinForms application that I've converted into a COM dll using
I have a .NET application that was written in C# and VB.NET using WinForms.
i have a .net winforms application that i want to be soundless. occasionally when
I have a datagridview in a c# .net WinForms application that captures order detail
I have a c# (.net 4.0) winforms application that runs pretty much every week
I have a .net 3.5 WinForms application that runs fine on my machine, but
I have a .net (2.0) winforms application that I need to upgrade on client

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.