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 6373113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:19:25+00:00 2026-05-25T01:19:25+00:00

Global meaning in one place e.g. not multiple try…catches e.g. on each event handler.

  • 0

Global meaning “in one place” e.g. not multiple try…catches e.g. on each event handler. Proven meaning “known to work” – I’m aware covering both .NET and other exceptions is not straightforward.

Thanks.

Solution coded from answers below.

Note: this is believed to cover exceptions from additional threads.

static class Program
{
    static void MyHandler(Exception e)
    { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }

    static void MyThreadExceptionEventHandler(object sender, ThreadExceptionEventArgs args)
    { MyHandler(args.Exception);
        // App continues.
    }

    static void MyAppExceptionHandler(object sender, UnhandledExceptionEventArgs args)
    { MyHandler((Exception)args.ExceptionObject);
        // There follows a OS "needs to close" dialog, terminating app.
    }

    static void Main()
    {

        // For UI thread exceptions
        Application.ThreadException += 
            new ThreadExceptionEventHandler(MyThreadExceptionEventHandler);

        // Force all Windows Forms errors to go through our handler.
        Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

        // For non-UI thread exceptions
        AppDomain.CurrentDomain.UnhandledException +=
            new UnhandledExceptionEventHandler(MyAppExceptionHandler);

        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}
  • 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-05-25T01:19:26+00:00Added an answer on May 25, 2026 at 1:19 am

    Handle the AppDomain.CurrentDomain.UnhandledException and the Application.ThreadException you should be good!

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

Sidebar

Related Questions

I'm writing a global error handling module for one of my applications. One of
Objective-C has no namespaces; it's much like C, everything is within one global namespace.
Global scope allows you to use a variable in a function that was defined
Global Windows hooks must be in a DLL because the hook is going to
Is global memory initialized in C++? And if so, how? (Second) clarification: When a
my global.asax looks like this Imports Castle.Windsor Imports Castle.Windsor.Configuration.Interpreters Public Class MvcApplication Inherits System.Web.HttpApplication
Regarding global variable initialization, function hello_testing() { global $conditional_random; if (isset($conditional_random)) { echo foo
Imagine in the Global.asax.cs file I had an instance class as a private field.
I have some global variables in a Python script. Some functions in that script
I am using a global named mutex for file access synchronization between an ASP.NET

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.