Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force exceptions language in English

My Visual Studio 2005 is a French one, installed on a French OS. All the exceptions I receive during debug or runtime I obtain also in French.

Can I however do something that the exceptions messages be in English? For goggling, discussing etc.

I tried the following:

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); throw new NullReferenceException(); 

obtained

Object reference not set to an instance of an object.

This is, surely, cool... but, as I work on a French project, I will not hardcode forcing Thread.CurrentUICulture to English. I want the English change to be only on my local machine, and don't change the project properties.

Is it possible to set the exceptions language without modifying the code of the application?


In VS 2008, set the Tools -> Options -> Environment -> International Settings -> Language to "English" wnd throwing the same exception obtain the ex message en French, however: alt text http://lh4.ggpht.com/_1TPOP7DzY1E/S1V62xcvHAI/AAAAAAAAC7o/ckLDVFPKh5Y/s800/exception.png

like image 241
serhio Avatar asked Jan 19 '10 09:01

serhio


2 Answers

You could set the current culture to English only in debug builds :

#if DEBUG Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); #endif 
like image 122
Thomas Levesque Avatar answered Oct 08 '22 20:10

Thomas Levesque


For the good of all future users of your application, place this to the Main method:

CultureInfo.DefaultThreadCurrentUICulture = Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; 

It will save them a good lot of trouble finding the English equivalent of a a badly translated error message.

like image 23
IS4 Avatar answered Oct 08 '22 19:10

IS4