-
Notifications
You must be signed in to change notification settings - Fork 529
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
Crash "Not a valid calendar for the given culture" with Thai locale #2511
Comments
Have same problem with arabic. Fixed it by using your workaround @velocitysystems. Thanks! |
@shnaz what was the workaround ? |
@AhmedKhattab95 Just call this method early in your MainActivity.OnCreate:
|
5 years since I reported this bug to bugzilla. Now got the hit from Arabic calendar. You should add code to the Application. Since Application is single, while there are many activities. And it's better to make PreventLinkerFromStrippingCommonLocalizationReferences static. Have not tried it, but it may be even not necessary to call the code in order to make linker work properly. https://guides.codepath.com/android/Understanding-the-Android-Application-Class |
In case it helps anyone in the future here is a larger method with all calendars based on the existing workarounds: private void PreventLinkerFromStrippingCommonLocalizationReferences()
{
_ = new System.Globalization.ChineseLunisolarCalendar();
_ = new System.Globalization.GregorianCalendar();
_ = new System.Globalization.HebrewCalendar();
_ = new System.Globalization.HijriCalendar();
_ = new System.Globalization.JapaneseCalendar();
_ = new System.Globalization.JapaneseLunisolarCalendar();
_ = new System.Globalization.JulianCalendar();
_ = new System.Globalization.KoreanCalendar();
_ = new System.Globalization.KoreanLunisolarCalendar();
_ = new System.Globalization.PersianCalendar();
_ = new System.Globalization.TaiwanCalendar();
_ = new System.Globalization.TaiwanLunisolarCalendar();
_ = new System.Globalization.ThaiBuddhistCalendar();
_ = new System.Globalization.UmAlQuraCalendar();
} |
Can it be called in the forms project. Or do I need to call it from Android, iOS projects separately? |
@Lelelo1 I had included it in my platform specific projects. But you could try it in the Forms project and see if it prevents the crashes. |
@BurkusCat |
With support for Classic Xamarin.Android ended May 1st, 2024, this issue is likely no longer relevant. If this still persists in .NET 8+, please open a new issue with updated information based on |
Steps to Reproduce
System.ArgumentOutOfRangeException
.Expected Behavior
The method should complete successfully.
Actual Behavior
Throws
System.ArgumentOutOfRangeException: Not a valid calendar for the given culture.
Workaround
Prevent linker from stripping out the reference by including it in the code.
Version Information
Microsoft Visual Studio Professional 2017 v15.9.3
VisualStudio.15.Release/15.9.3+28307.145
Microsoft .NET Framework
Version 4.7.03062
Xamarin 4.12.3.73 (d15-9@20b35b881)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 4.16.5 (6b9f32067)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 1.1.127 (e975299)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 9.1.0.38 (HEAD/61d16aa23)
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK 12.2.1.11 (5ef73d3)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Related
Previously reported:
The text was updated successfully, but these errors were encountered: