Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The type initializer for 'Humanizer.Configuration.Configurator' threw an exception. #373

Closed
yenelcs opened this issue Jan 22, 2015 · 5 comments · Fixed by #374
Closed

The type initializer for 'Humanizer.Configuration.Configurator' threw an exception. #373

yenelcs opened this issue Jan 22, 2015 · 5 comments · Fixed by #374

Comments

@yenelcs
Copy link

yenelcs commented Jan 22, 2015

System.TypeInitializationException: The type initializer for 'Humanizer.Configuration.Configurator' threw an exception. ---> System.Globalization.CultureNotFoundException: Culture is not supported.
Parameter name: name
zh-CHS is an invalid culture identifier.
at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
at System.Globalization.CultureInfo..ctor(String name)
at Humanizer.Configuration.FormatterRegistry.RegisterDefaultFormatter(String localeCode)
at Humanizer.Configuration.FormatterRegistry..ctor()
at Humanizer.Configuration.Configurator..cctor()
--- End of inner exception stack trace ---
at Humanizer.TimeSpanHumanizeExtensions.d__4.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Linq.Enumerable.<takeiterator>d__3a1.MoveNext()
at System.String.Join(String separator, IEnumerable`1 values)
at Humanizer.TimeSpanHumanizeExtensions.Humanize(TimeSpan timeSpan, Int32 precision, Boolean countEmptyUnits, CultureInfo culture)
at Humanizer.TimeSpanHumanizeExtensions.Humanize(TimeSpan timeSpan, Int32 precision, CultureInfo culture)
at Flashlight.MainPage.SetBatteryText(Int32 remainingChargePercent, TimeSpan remainingDischargeTime)
at Flashlight.MainPage.LoadUIComponents()
at Flashlight.MainPage.b__2d()
--- Inner exception of type System.Globalization.CultureNotFoundException start ---
--- Message: Culture is not supported. Parameter name: name zh-CHS is an invalid culture identifier. ---
System.Globalization.CultureNotFoundException: Culture is not supported.
Parameter name: name
zh-CHS is an invalid culture identifier.
at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
at System.Globalization.CultureInfo..ctor(String name)
at Humanizer.Configuration.FormatterRegistry.RegisterDefaultFormatter(String localeCode)
at Humanizer.Configuration.FormatterRegistry..ctor()
at Humanizer.Configuration.Configurator..cctor()
--- End of inner exception stack trace ---

@MehdiK
Copy link
Member

MehdiK commented Jan 25, 2015

Thanks for reporting this. This is really strange.

The error says zh-CHS can't be used as a culture identifier, and CultureInfo constructor is throwing on that code while there are passing unit tests in the solution that are instantiating CultureInfo for zh-CHS!!

Is that the locale you're using? Would you be able to send a failing test for this issue?

@yenelcs
Copy link
Author

yenelcs commented Jan 25, 2015

zh-CHS and zh-CHT are legacy and it throws exception when you run on Windows phone. You must be running test on the PC. It passes on the PC but fails on the phone.

https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.parent
Specific cultures should be use instead of legacy ones.

@MehdiK
Copy link
Member

MehdiK commented Jan 26, 2015

I fixed that in #374 and it's now been released to NuGet. Please check if it's fixed now.

@yenelcs
Copy link
Author

yenelcs commented Jan 27, 2015

It works fine now. Thanks.

@MehdiK
Copy link
Member

MehdiK commented Jan 28, 2015

Thanks for reporting and for the link to right culture codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants