WPF C#:由于客户端“区域和语言”而开始崩溃;设置

发布于 2024-09-03 08:30:16 字数 514 浏览 5 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我很OK 2024-09-10 08:30:16

啊不,我想我已经找到了。

它设置的枚举值位于静态类中,该类有一些日期时间值,因此当它首先设置这些值时,由于日期格式差异而崩溃!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文