Search Issue Tracker

Fixed in 2021.1.X

Fixed in 2019.4.X, 2020.3.X



Found in






Issue ID




System.DateTime causes ArgumentOutOfRangeException in Windows Standalone Player with "Thai" Windows system language



How to reproduce:
1. Open the attached project
2. Build the project
3. Make sure your Windows system language is set to "Thai"
4. Run the build

Actual result: ArgumentOutOfRangeException gets thrown when trying to get the System.DateTime.

Reproducible with: 2019.3.0a5, 2019.2.0b5, 2019.1.5f1, 2018.3.14f1, 2018.2.21f1.

Reproducible only with IL2CPP backend.

2018.2 and 2018.3 sometimes show the wrong DateTime and no issues appear. (Date should be 543 years ahead of the Gregorian calendar).
But if Unity tries to show the right DateTime it crashes on C++ Runtime Error.

  1. Resolution Note (fix version 2021.1):

    Fixed in 2021.1.0a1

    For older releases:

    In order to use the Thai locale, the System.Globalization.ThaiBuddhistCalendar type must be included in the build. This type is referenced in the class library code via reflection, so it will be removed by the managed code stripping process by default. (Not that managed code stripping is enabled for IL2CPP and disabled for Mono by default, hence the difference in behavior).

    Use a link.xml file (in the Assets directory of the project) with the following content to correct this issue:

    <assembly fullname="mscorlib">
    <type fullname="System.Globalization.ThaiBuddhistCalendar" preserve="all"/>

    Note that this same issue could happen with System.Globalization.UmAlQuraCalendar and System.Globalization.HijriCalendar

    More details about managed code stripping are available here:

  2. Resolution Note (fix version 2020.3):

    Fixed in 2020.3.26f1

  3. Resolution Note (fix version 2019.4):

    Fixed in 2019.4.35f1

Comments (1)

  1. IvanHomichkovWannaplay

    Apr 21, 2022 08:41

    As an alternative to linker file (where you specify that u want all calendars in your build) u can somewhere in your code reference required calendars. That will prevent stripping.

    For example call something easy as that
    new System.Globalization.ThaiBuddhistCalendar();

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.