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

  • SEARCH
  • Home
  • 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 8041845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:21:44+00:00 2026-06-05T04:21:44+00:00

Currently, when there is an unhandled error in one of the forms in my

  • 0

Currently, when there is an unhandled error in one of the forms in my Windows Forms program, a dialog pops up with lots of details which are irrelevant and confusing to the end user.

I would like to replace that dialog with a more user-friendly dialog (and use a Tabbed interface to hide but make available technical details) whenever an unhandled error occurs in one of my forms.

Is there a way to replace this default dialog with a custom one?

My application is an MDI one, so if an error occurs in a form, I would like to just close out that form, show the error in a friendly way and allow them to work with other windows in the application (unless its a critical error).

  • 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-05T04:21:46+00:00Added an answer on June 5, 2026 at 4:21 am

    A couple of ways spring to mind. Easiest one is to catch all unhandled exceptions by listening to the Application.ThreadException event

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);           
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.Run(new Form1());
        }
    
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.Message);
        }
    

    However that would simply stop the crashing and not close the mdi form. If you stop the sending thread, it would stop the mdi form altogether (it’s easier outside mdi, then the forms can run in separate threads which can be initiated sandboxed).

    What I normally do is run all code sandboxed. Normally encapsulated inside an action object, but i could be a simple procedure e.g.

        public static bool Run(Action a)
        {
            try
            {
                a();
                return true;
            }
            catch(Exception ex)
            {
                //custom error handling here
                return false;
            }
        }
    

    example call:

        private void button1_Click(object sender, EventArgs e)
        {
            Run( ()=>throw new Exception());
        }
    

    Running in a standard method has the added benefit of being able to control things as a wait cursor or logging. If it wasn’t an mdi environment, there would be some alternatives, but hope this one is doable.

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

Sidebar

Related Questions

There Currently is a local debate as to which code is more readability We
I have a page where there is currently more than one form. I used
As far as I know, there is currently no JAXB implementation which would work
I have been using the storyboard to make an application and currently there are
we are using data sets as our data access layer. currently there are some
Is there currently a way to generate XML files containing tables compatible with Microsoft
Is there currently a way to subscribe to an event of a wrapped set,
There is currently this Prototype code that does a PUT: new Ajax.Request(someUrl, { method:
I know that there are currently questions on SO already pertaining to saving jQuery
I want to start findBugs on existing project (on command line there are currently

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.