Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
540 views
in Technique[技术] by (71.8m points)

.net - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

#if DEBUG
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
#endif

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...