WPF C#:由于客户端“区域和语言”而开始崩溃;设置
我正在开发一个 WPF C# 应用程序,它似乎与一些随机的人一起崩溃。
所以最终我发现是“区域和语言”设置造成的。
例如,如果我将格式设置为英语(美国),它将起作用,如果我将其设置为瑞典语(瑞典),它将从一开始就崩溃。
当我在 Visual Studio 2010 中测试它时,它给出错误“TypeInitializationException”。更准确地说,它在这里执行此操作(它不会传递 InitializeComponent() void):
private void RadioButton_Checked(object sender, RoutedEventArgs e) {
Info.SortOrder = SortBy.Rank;
}
它在第一行声明错误,这只是为变量设置枚举值。我想它只是在那里做,因为这是它做的第一件事,或者其他什么。
有人知道如何解决这个问题吗?我已经四处搜索,但似乎无法找到方法:(
非常感谢任何帮助!
谢谢
I'm working on a WPF C# application, and it seems to crash with a few random people.
So eventually I found out it was the 'Region and Language' settings that was responsible.
For example, if I were to set my Format to English (United States) it will work, if I set it to Swedish (Sweden) it will crash from the start.
When I test this in Visual Studio 2010 it gives error 'TypeInitializationException'. More precisely it does it here (it doesn't get passed the InitializeComponent() void):
private void RadioButton_Checked(object sender, RoutedEventArgs e) {
Info.SortOrder = SortBy.Rank;
}
It claims the error at the first line, which is just setting an enum value to a variable. I guess it's just doing it there because it's the first thing it makes, or something.
Anyone has any idea how to fix this? I've searched around but can't seem to find out how :(
Any help is much appreciated!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊不,我想我已经找到了。
它设置的枚举值位于静态类中,该类有一些日期时间值,因此当它首先设置这些值时,由于日期格式差异而崩溃!
Ahh no, I think I've found it.
The enum value it was setting to was in a Static class, which had a few DateTime values, so when it was settings those values first, it crashed due to the Date format difference!