Resolved Force Windows Default Message Display In English

SiamIT

Active member
Joined
Aug 3, 2021
Messages
40
Programming Experience
5-10
Greetings,
I develop software for numerous clients around the world, and many of the clients is from non English country thus their computer Language is also non English.

And sometimes, when my app face Unhandled exception it shows the error message with details. But problem is windows shows those error message using user local language settings.

That's why i am using following solution was able to show custom Exception Window.

Stackoverflow Support:
https://stackoverflow.com/a/11591200/12938841

but on the site (at user end) it still shows the message as windows local language :( . Please check the following screenshot:

Excepton.png


so; my question is how can i force that message to be shown in English discarding user windows default/current language settings?

thanks in advance

best regards
 
Set the current culture when your app starts.


 
Set the current culture when your app starts.



i am sorry, but i have tried that.. and didn't work.. it still shows the message in user local language; not in English :(

Used Code:
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.CurrentCulture = new CultureInfo("en-US");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.Run(new frmMain());
        }

        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception ex = (Exception)e.ExceptionObject;
            string msg = "Unhandled exception has Occurred in your Application.";
            msg += "If you like to see the exception details then click on Show Details button, otherwise click on Quit button to terminate the application!";
            msg += Environment.NewLine + Environment.NewLine + ex.Message;
            ErrorForm form = new ErrorForm()
            {
                Text = Common.GetAppInfo(Common.AppInfo.Title) + " v" + Common.GetAppInfo(Common.AppInfo.Compact),
            };
            form.WarningLabel.Text = msg;
            form.DetailsTextbox.Text = ex.ToString();
            form.ShowDialog();
            form.Dispose();
            Environment.Exit(-1);
        }
    }

although thanks a lot for your kind reply..
 
Change to CultureInfo.CurrentUICulture =
Exception class gets the message from resources for that culture:
1671557758021.png
 
Solution
Back
Top Bottom