【发布时间】:2014-04-17 13:28:18
【问题描述】:
我现在正在本地化我的 WPF 应用程序,在 MainWindow 的构造函数中有这段小代码:
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Settings.Default.Language);
我一启动它就崩溃了,说:
XmlParseException:{"'The invocation of the constructor on type 'Program.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'."}
its inner: CultureNotFoundException: Culture is not supported. Parameter name: nameen-UK is an invalid culture identifier.
现在我知道没有像 en-UK 这样的文化名称。我只是偶然输入了一次...我以为有。
现在所有内容都包含:en-GB。 (设置、appconfig 等)
我已经完成的步骤:
- 重启开发环境
- 删除所有 bin 和 obj 文件夹。
- 在整个解决方案中搜索以下表达式:“en-UK”(区分大小写和不区分大小写)
- 与总指挥官一起搜索包含以下文本的“asterisk dot asterisk”:“en-UK”(区分大小写和不区分大小写)
没有结果...
然后我在构造函数中放了一个断点
Settings.Default.Language
具有“en-UK”的值。
要点:在发布模式下一切正常。它仅在调试模式下发生。这怎么可能?
在发布模式下,Settings.Default.Language 具有 en-GB 值(这很好)。
你以前遇到过这个问题吗?是 Visual Studio 的错误还是我发疯了?谢谢。
【问题讨论】:
-
我很久以前学到的一条经验法则,我推荐的是,如果我认为这是 Visual Studio 中的错误,那绝不是 - 这是我在某个地方搞砸了。
-
真的,真的。我也经历过很多次……
标签: c# wpf visual-studio settings culture