Reputation: 3430
How to display MSSQL exception messages in C# in a specified language (English) instead of in the UI language?
I tried changing the thread's CultureInfo but it didn't change anything.
Upvotes: 0
Views: 1265
Reputation: 4284
It is not related with CultureInfo, if you want to use different languages in your Exception messages, you need to install .NetFramework Language update. For ex, if you install arabic .net framework, you exception messaages appear like arabic
Upvotes: 2
Reputation:
:( Unfortunately there is no good solution in my mind,
All i can say is to handle each exception in separate catch block.
like:
catch(TimoutException ex) { }
catch(CommunicationException ex) { }
and get appropriate exception message from your global resource.
Upvotes: 1
Reputation: 3318
The message is generated on the SQL Server. How should the Framework do the translation?
What I do is to divide the exceptions in two types:
Then for logging the exception into the application log etc. I prefer using the english text. This garanties that most of the developer or system administrators understand what is going on.
For error handling you might take a look at ELMAH.
Upvotes: 1