在英语中强制异常语言 [英] Force exceptions language in English

查看:196
本文介绍了在英语中强制异常语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Visual Studio中的 2005 的是法国的,安装了法国的操作系统。 所有的异常我调试或运行时我还得到法国接收过程。

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.

我可以但是做一些例外的消息在英语说?对于goggling,讨论等。

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

我试过如下:

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

获得

对象引用未设置到对象的实例。

这是,当然,爽......可是,我工作在一个法国的项目,我不会硬code迫使Thread.CurrentUICulture为英语。我想英文变化只在我的本地机器,不改变项目属性。

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.

是否可以设置例外语言的无需修改 code 的应用程序?

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

在VS的 2010 的,设置工具 - >选项 - >环境 - >国际设置 - >语言为英语WND抛出同样的异常获得前消息EN法语,但是:

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:

推荐答案

最后一个尖锐的解决方案可能是以下内容:

Finally a "sharp" solution could be the following:

[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);

#if DEBUG
    // Add this; Change the Locales(En-US): Done.
    Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
#endif

    Application.Run(new Form1());
}

不过,我想没有修改项目的解决方案的 code 的。

MSDN

的CurrentUICulture 属性会   设置隐如果应用程序不   指定的的CurrentUICulture 的。如果   的CurrentUICulture 的未明确设置   在应用程序的code,它是由设置   在 GetUserDefaultUILanguage 功能   在Windows 2000和Windows XP   多语言用户界面(MUI)   制品,其中最​​终用户可以设置   默认语言。如果用户的UI   语言没有设置,它将被设置   系统安装的语言,这   是操作的语言   系统的资源。

The CurrentUICulture property will be set implicitly if an application does specify a CurrentUICulture. If CurrentUICulture is not set explicitly in an application's code, it is set by the GetUserDefaultUILanguage function on Windows 2000 and Windows XP Multilingual User Interface (MUI) products where the end user can set the default language. If the user's UI language is not set, it will be set by the system-installed language, which is the language of the operating system's resources.

如果一个应用程序是基于Web的,在   的CurrentUICulture 可以明确地设置   在应用code送至用户的   浏览器接受的语言。

If an application is Web-based, the CurrentUICulture can be set explicitly in application code to the user's browser accept language.

这篇关于在英语中强制异常语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆