For the device to show a more detailed error message, I uninstalled the .NET Compact Framework version 2.0 that comes bundled with the device and let Visual Studio automatically install the framework before debugging in started. With this change, the exact error message pops up, showing an ArgumentOutOfRangeException when the program tries to call DateTime.ToString(). With some further investigation, I realized this seems to be an issue with the .NET Compact Framework when running on phones where the user has changed the default language in Regional Settings to Chinese. In all my test devices, the problem seems to only happen on HTC phones with the language set to Chinese (Singapore) and strangely does not occur when a different Chinese dialect (e.g. Chinese (Taiwan)) is used.
To use Chinese (Singapore) as the phone's default localization, a workaround is to open Region Settings, in the Date tab, under Calendar Type, select another type of calendar such as 西历, instead of Gregorian Calendar.
The problem may have to do with the fact that HTC phones allow user to switch between 西历 and Gregorian Calendar. On other phones that do not have this problem the option Calendar Type is grayed out, default to 西历, and thus cannot be changed if the localization is set to Chinese.
Interestingly, when this problem happens, a Try/Catch around the related code section does not always prevent the crash. If it does, further execution of the program may have erratic behaviour such as throwing mysterious ArgumentOutOfRangeException or returning wrong results when calculating date/time values.
Upgrading to .NET Compact 3.5 does not fix the problem.

No comments:
Post a Comment
Note: Only a member of this blog may post a comment.