|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Exception messages in localized applicationWe've got a VB.NET application which is localized. I would like to make sure that any exceptions are logged to our application's log file in English, not the currently selected language. The problem is that by the time we get into the exception handling routine (via the try...catch...end try construct), the exception has already been created, and its message etc. is in the current culture. For example, we get the following ex.message: System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet. at Capture.clsCapture.ReadINI(CaptUDT& mini) in C:\p4\Capture\Capture1.vb:line 348 While the exception type (System.NullReferenceException) is helpful to us - as it's still in English - we really need the message in English. Any thoughts? Thanks, James AFAIK, the exception text depends on the language of the installed .NET
Framework and not on the current culture, because the .NET Framework does not contain the text of all languages, it is a localized component . So, you must install the English version of the .NET Framework to get English messages. Another approach is to hardcode in your app the text of all exception messages in English (generated on an English computer) and code a function that gets the Exception type and returns the English message. -- Carlos J. Quintero MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET You can code, design and document much faster. http://www.mztools.com <ja***@microsec.co.uk> escribió en el mensaje news:1105614443.611143.315240@f14g2000cwb.googlegroups.com... We've got a VB.NET application which is localized.Hi all, I would like to make sure that any exceptions are logged to our application's log file in English, not the currently selected language. The problem is that by the time we get into the exception handling routine (via the try...catch...end try construct), the exception has already been created, and its message etc. is in the current culture. For example, we get the following ex.message: System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet. at Capture.clsCapture.ReadINI(CaptUDT& mini) in C:\p4\Capture\Capture1.vb:line 348 While the exception type (System.NullReferenceException) is helpful to us - as it's still in English - we really need the message in English. Any thoughts? Thanks, James Hi Carlos,
Thanks for the reply. My experience has shown that the exception text is based on the current culture at the time the exception is created. I've got the English ..NET Framework, with the French .NET Framework language pack also installed. When I'm running with French culture, exception messages are in French (even if I temporarily switch back to English in code to print to our application's log file). I will look into your suggestion of hardcoding the texts, though - thanks. James Carlos J. Quintero [.NET MVP] wrote: Show quote > AFAIK, the exception text depends on the language of the installed ..NET > Framework and not on the current culture, because the .NET Framework does > not contain the text of all languages, it is a localized component . So, you > must install the English version of the .NET Framework to get English > messages. > > Another approach is to hardcode in your app the text of all exception > messages in English (generated on an English computer) and code a function > that gets the Exception type and returns the English message. > > -- > > Carlos J. Quintero > > MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET > You can code, design and document much faster. > http://www.mztools.com > > > <ja***@microsec.co.uk> escribió en el mensaje > news:1105614443.611143.315240@f14g2000cwb.googlegroups.com... > Hi all, > We've got a VB.NET application which is localized. > > I would like to make sure that any exceptions are logged to our > application's log file in English, not the currently selected language. > > The problem is that by the time we get into the exception handling > routine (via the try...catch...end try construct), the exception has > already been created, and its message etc. is in the current culture. > > For example, we get the following ex.message: > System.NullReferenceException: La référence d'objet n'est pas > définie à une instance d'un objet. > at Capture.clsCapture.ReadINI(CaptUDT& mini) in > C:\p4\Capture\Capture1.vb:line 348 > > While the exception type (System.NullReferenceException) is helpful to > us - as it's still in English - we really need the message in English. > Any thoughts? > > Thanks, > > James |
|||||||||||||||||||||||