强制.NET Framework中英文例外 [英] Forcing English language exceptions in .NET framework

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

问题描述

虽然在ASP.NET MVC的工作,我已经注意到由安装在我的系统。NET框架发布了异常信息都在德国。我真的preFER英文消息,这样我就可以在post它们。

While working with ASP.NET MVC, I have noticed that exception messages issued by the .NET framework installed on my System are in German. I'd really prefer English messages, so I can post them on SO.

我知道这已被要求之前,SO,但没有建议的解决方法奇怪的是好像在我的情况下工作。我已经试过如下:

I know this has been asked before on SO, but strangely enough none of the suggested workarounds seem to work in my case. I have already tried the following:


  • 交换我的Windows系统,在英语语言环境并重新启动Visual Studio中

  • 设置工具 - >选项 - >环境 - >国际设置 - >语言为英语

  • 设置线程区域设置为英语抛出异常权利之前如下:

  • switching my Windows system to an English locale and restarting Visual Studio
  • Setting Tools -> Options -> Environment -> International Settings -> Language to "English"
  • setting the thread locale to English right before the exception is thrown as follows:

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(EN-US);
Thread.CurrentThread.CurrentUICulture =新的CultureInfo(EN-US);

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture ("en-US"); Thread.CurrentThread.CurrentUICulture=new CultureInfo("en-US");

//调用我的方法有问题...

//call my faulty method...

所以,我怎么能在.NET框架的问题,英语语言异常消息?而且是有,这是否每个解决方案,甚至是整个系统的基础上,任何方法呢?

So, how can I make the .NET framework issue English language exception messages? And is there any approach that does this on a per-solution or even system-wide basis?

编辑:的异常而excuting我的单元测试抛出。我不知道这是什么原因设置线程的文化已经不能大意。

The exception is thrown while excuting my unit tests. I am not sure if this is the reason setting the thread's culture had not effect.

推荐答案

正如我刚才发现,问题确实涉及到具有不同的测试项目。虽然我已经尝试设置界面语言为英语在我的实际项目中,我没有做的测试项目,这就是为什么异常消息看测试结果时,德国仍然是相同的。

As I just found out, the problem was indeed related to having a different test project. While I have tried setting the UI language to English in my actual project, I did not do the same in the test project, which is why the exception messages were still in German when looking at the test results.

设置权之前抛出异常的伎俩,我在测试方法的用户界面语言。

Setting the UI language in the test method right before the exception is thrown did the trick for me.

这篇关于强制.NET Framework中英文例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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