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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:55:05+00:00 2026-05-18T06:55:05+00:00

I developed a desktop application, it’s almost done but still contains some bugs which

  • 0

I developed a desktop application, it’s almost done but still contains some bugs which I’m eliminating.

I use a general [try…catch] block wrapped around my application

[STAThread]
static void Main()
{
   try
   {
       program = new Program();
       // ...
   }
   catch (Exception x)
   { 
       // ...
       MessageBox.Show(
          message,
          Resources.MESSAGEBOX_ERROR_CRASH_Caption,
          MessageBoxButtons.OK,
          MessageBoxIcon.Error);
   } 
}

my Program class constructor being:

public Program()
{
    // [...]
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    // [...]
    frmLogon = new Logon();            
    Application.Run(frmLogon);
}        

to ensure that any unhandled exception will bubble all the way up the stack and is at least responded to with some communicative message box.

It works fine when I run the application under Visual Studio (debug mode), but when I deployed it and installed on my PC, it doesn’t – that’s what I get when the bug (which I’ve already identified, by the way) causes it to read from a null array

alt text

Why? It baffles me really. Why was it “unhandled”? It was my understanding that try…catch should work regardless of whether it’s release or debug mode, otherwise what would be the point.

  • 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-18T06:55:06+00:00Added an answer on May 18, 2026 at 6:55 am

    This is kind of old, but if you still need a solution, you need to handle some events, enclosing the entire thing in a try catch won’t work. Do something like this:

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            AppDomain.CurrentDomain.UnhandledException += ProcessAppException;
            Application.ThreadException += ProcessThrException;
            Application.Run(new MainForm());
        }
    
        private static void ProcessAppException(object sender, UnhandledExceptionEventArgs e)
        {
            XtraFunctions.LogException((Exception)e.ExceptionObject);
            throw (Exception)e.ExceptionObject; //MessageBox in your case.
        }
    
        private static void ProcessThrException(object sender, ThreadExceptionEventArgs e)
        {
            XtraFunctions.LogException(e.Exception);
            throw e.Exception; //MessageBox in your case.
        }
    

    When an exception isn’t caught, it will go through one of those before displaying the exception dialog. So you have the option to override it and display a nice message of your choice.

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

Sidebar

Related Questions

I am writing a desktop application written in Swing developed using Java 1.5. Some
From a desktop application developer point of view, is there any difference between developing
Consider the need to develop a lightweight desktop DB application on the Microsoft platforms.
I need to develop a small-medium sized desktop GUI application, preferably with Python as
Imagine that you want to develop a non-trivial end-user desktop (not web) application in
When developing whether its Web or Desktop at which point should a developer switch
I'm a full time web developer but I have my roots as a desktop
I recently developed a Java Application for a client with MySQL database . Now
I work on a desktop application and I send frequent betas to testers using
I develop a number of desktop Java applications using Swing, and while Swing is

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.