Record and display .NET exceptions in multiple languages

I log my application's .NET error messages and exceptions in the database and display them in a graphical interface. The GUI displays error messages in the language of the user starting the application. To do this, I register resource names of only error messages and turn them into meaningful messages using resource files.

However, I cannot turn my head around how to achieve the same for standard .NET exception messages. I can only register a message line, but then the language is already β€œbaked”, so I can only display an exception in this one language.

Is there a way to get the name of the .NET + exception resource + all the parameters that are inserted into the message line so that I can register them?

+8
c # exception-handling internationalization
source share
2 answers

There is no such thing as a resource name for an exception, but there is a HResult property of the Exception class . Standard . NET framework exceptions have valid and unique HResult numbers , which you can then map to your own resource identifier, which you can then translate. In addition, there is the Exception.Data property, which may contain additional information about the exception.

Or you can manually parse the exception messages using a regular expression or the like and then match your resource id, but this is too much effort, I think.

+2
source share

I also had this problem, and I did a lot of research. Based on everything I could say, there was no way to localize the exception, because what you see is not localized strings, this is actual code. The code is written in only one language (English) and can only be displayed as such.

0
source share

All Articles