Exception messages in en-US only

StewartBW 1,235 Reputation points
2025-03-11T14:33:45.82+00:00

Hello

I've placed an exception sender in my VB.net app which in case of exceptions, will send them to me to check, seems on localized systems, the messages are not in en-US and I get them like this:

Exception Message: Erro genérico em GDI+.

Root Exception: System.Runtime.InteropServices.ExternalException (0x80004005): Erro genérico em GDI+.

How to get the exceptions internally as en-US only? Not going to change it globally in the app, the exceptions messages to the user should remain in localized language, just the one I need to send to myself, how to get it in English only?

Thanks.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,799 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 33,781 Reputation points Microsoft External Staff
    2025-03-11T14:47:34.2+00:00

    Hi @Anonymous ,

    You can try temporarily switching to en-US.

    1. Save the current culture so you can restore it later.
    2. Temporarily set the thread's culture to en-US using Thread.CurrentThread.CurrentCulture.
    3. Send the exception message and stack trace.
    4. Restore the original culture to ensure the rest of the application behaves as expected.

    Best Regards.

    Jiachen Li


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.