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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:38:06+00:00 2026-06-10T06:38:06+00:00

What is the difference between release mode and debug mode? And how can I

  • 0

What is the difference between release mode and debug mode?

And how can I debug in release mode to see whats failing?

class Program
{
    [STAThread]
    static void Main()
    {
        try
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainWindow());
        }
        catch (Exception ex)
        {
            Logger.Error("Main : "+ex.Message, typeof(Program));
            MessageBox.Show(ex.Message + ex.StackTrace);
            Environment.Exit(1);
        }
    }
}
  • 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-10T06:38:08+00:00Added an answer on June 10, 2026 at 6:38 am

    The catch clause in your snippet will never catch anything in the shipping version of your app. It does work when you run it with a debugger attached.

    What you are missing is the way Application.ThreadException behaves. That event fires whenever any unhandled exception is detected. This feature however is not enabled when you debug your code. No exception handler is installed to raise the event. This was done so you have a decent way to debug unhandled exceptions. Your code changes that behavior, now there is a try block active, your catch handler gets the exception.

    To get the code to behave the same way, you’ll need to change the unhandled exception handling strategy. Like this:

        [STAThread]
        static void Main() {
            try {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
                Application.Run(new Form1());
            }
            catch (Exception ex) {
                // etc..
            }
        }
    

    Now your catch clause will always catch the exception. As long as it is raised on the main thread, it won’t catch exceptions raised in worker threads. Consider this code instead for unified handling:

        [STAThread]
        static void Main() {
            AppDomain.CurrentDomain.UnhandledException += AllUnhandledExceptions;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
            Application.Run(new Form1());
        }
    
        private static void AllUnhandledExceptions(object sender, UnhandledExceptionEventArgs e) {
            var ex = (Exception)e.ExceptionObject;
            // Display or log ex.ToString()
            //...
            Environment.Exit(System.Runtime.InteropServices.Marshal.GetHRForException(ex));
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I use Trace.WriteLine in release mode? And what is the main difference between
Possible Duplicate: self.prop=nil; vs. [prop release];prop=nil; Can anyone help, What is the difference between
Can anyone tell me the difference between [self.property release] and [property release] . I
The title says What is the difference between release and iteration? Can you explain
I think that I understand the difference between Release and Debug build modes. The
Possible Duplicate: Debug vs. release in .NET Debug/Release difference What is the difference between
Possible duplicate Debug Visual Studio Release in .NET What is the difference between Debug
I am wondering what the difference is between release and dealloc? After reading, the
What are the difference between a public class member class data { public: std::list<data>
Can any one explain difference between position and anchor point in cocos-2D with some

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.