[英]Windows Phone DateTime exception
我目前正在本地化Windows Phone應用程序,但已經開始在DateTime.Now.ToString()上獲取索引超出范圍異常。
我嘗試更改計算機的時區,但錯誤仍然存在。
我不確定是什么原因導致了此問題,或者該如何解決。
有任何想法嗎? 提前致謝!
堆棧跟蹤(按要求添加)
mscorlib.dll!System.Globalization.DateTimeFormatInfo.GetYearMonthPattern(int calID = 1) + 0x25 bytes
mscorlib.dll!System.Globalization.DateTimeFormatInfo.InitializeOverridableProperties() + 0x94 bytes
mscorlib.dll!System.Globalization.DateTimeFormatInfo.Calendar.set(System.Globalization.Calendar value = {System.Globalization.GregorianCalendar}) + 0x1a8 bytes
mscorlib.dll!System.Globalization.DateTimeFormatInfo.DateTimeFormatInfo(System.Globalization.CultureTableRecord cultureTable = {System.Globalization.CultureTableRecord}, System.Globalization.Calendar cal = {System.Globalization.GregorianCalendar}) + 0x29 bytes
mscorlib.dll!System.Globalization.CultureInfo.DateTimeFormat.get() + 0x19 bytes
mscorlib.dll!System.Globalization.CultureInfo.GetFormat(System.Type formatType = {Name = "DateTimeFormatInfo" FullName = "System.Globalization.DateTimeFormatInfo"}) + 0x22 bytes
mscorlib.dll!System.Globalization.DateTimeFormatInfo.CurrentInfo.get() + 0x2a bytes
mscorlib.dll!System.DateTime.ToString()
> QuickAirtime.dll!QuickAirtime.PaymentSummary.btnTransactionClick(object sender = {System.Windows.Controls.Button}, System.Windows.RoutedEventArgs e = {System.Windows.RoutedEventArgs}) Line 78 + 0x2 bytes C#
System.Windows.dll!System.Windows.Controls.Primitives.ButtonBase.OnClick() + 0x1f bytes
System.Windows.dll!System.Windows.Controls.Button.OnClick() + 0x1f bytes
System.Windows.dll!System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e = {System.Windows.Input.MouseButtonEventArgs}) + 0x4e bytes
System.Windows.dll!System.Windows.Controls.Control.OnMouseLeftButtonUp(System.Windows.Controls.Control ctrl = {System.Windows.Controls.Button}, System.EventArgs e = {System.Windows.Input.MouseButtonEventArgs}) + 0xc bytes
System.Windows.dll!MS.Internal.JoltHelper.FireEvent(System.IntPtr unmanagedObj = 227599168, System.IntPtr unmanagedObjArgs = 227256368, int argsTypeIndex = 169, int actualArgsTypeIndex = 169, string eventName = "M@@4") + 0x115 bytes
[External Code]
我的應用程序已本地化,並且未使用正確格式的區域性代碼,例如,我將使用en代替en-US或使用fr代替fr-FR。
如上所述,一旦我變得很具體, DateTime.Now.ToString()
開始按預期工作。
如果日期對於當前區域性的日歷無效,則可能發生這種情況。
根據MSDN文檔 : ToString()方法返回當前區域性所使用的日歷中日期和時間的字符串表示形式。 如果當前DateTime實例的值早於Calendar.MinSupportedDateTime或晚於Calendar.MaxSupportedDateTime,則該方法將引發ArgumentOutOfRangeException 。
您的應用當前的文化是什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.