views:

38

answers:

1

Hi, 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

A: 

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!

FrieK