Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2005

Tip: Looking for answers? Try searching our database.

Exception messages in localized application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
james@microsec.co.uk - 13 Jan 2005 11:07 GMT
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
Carlos J. Quintero [.NET MVP] - 13 Jan 2005 13:58 GMT
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.

Signature

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

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
james@microsec.co.uk - 14 Jan 2005 08:06 GMT
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

> 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.
[quoted text clipped - 30 lines]
>
> James

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.