Pergunta

I'm now localizing my WPF application and there is this little piece of code in the constructor of the MainWindow:

System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Settings.Default.Language);

It crashes right after I start it, saying:

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.

Now I know that there is no such a culture name as en-UK. I just typed it once by accident... I thought there was.

Now everything contains: en-GB. (settings, appconfig, etc.)

Steps I have done:

  • restart devenv
  • delete all the bin and obj folders.
  • search in the entire solution for the expression: "en-UK" (with and without case sensitivity)
  • search with total commander for "asterisk dot asterisk" containing the text: "en-UK" (with and without case sensitivity)

no results...

Then I put a breakpoint into the constructor and the

Settings.Default.Language

has the value "en-UK".

The point: everything works fine in release mode. It occurs only in Debug mode. How is this possible?

in release mode, the Settings.Default.Language has the en-GB value (which is fine).

Have you met this problem before? Is it a Visual Studio bug or did I go mad? Thank you.

Foi útil?

Solução

in Visual Studio the debug mode or the release mode each one have a separated config file; so when you debug with Debug config the old config info still registered; try to make like this in the constructor:

Setting.Default.Reset();

if this not help you please post some code for more detail.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top