2012-06-28 2 views
0

현재 Windows Phone 응용 프로그램의 현지화 작업을하고 있지만 DateTime.Now.ToString()에서 범위를 벗어나는 색인을 얻는 중입니다.Windows Phone DateTime 예외

내 컴퓨터의 시간대를 변경해 보았지만 오류가 지속됩니다.

이 문제의 원인이나 해결 방법을 잘 모르겠습니다.

아이디어가 있으십니까? 미리 감사드립니다! (요청시 추가)


스택 추적


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 = "[email protected]@4") + 0x115 bytes  
    [External Code] 
+5

정말 예외가 DateTime.Now.ToString()에 의해 throw되는지 확실합니까? 그건 불가능 해 보입니다. (예외 스택 추적을 게시하십시오.) –

+0

@PhilippeLeybaert StackTrace를 보여주기 위해 질문을 편집했습니다. – user1477707

+0

예외가 발생하는 실제 코드 줄과 그 주변의 몇 줄을 보여줄 수 있습니까? 그 오류를 재생산? 또한 : 당신은 에뮬레이터/전화 장치에서 지원하지 않는 문화를 강요하고 있습니까? –

답변

0

날짜가 현재 문화의 일정에 유효하지 않은 경우이 발생할 수 있습니다.

MSDN documentation에 따라 : ToString() 메서드는 현재 문화권에서 사용하는 달력의 날짜와 시간의 문자열 표현을 반환합니다. 현재 DateTime 인스턴스의 값이 Calendar.MinSupportedDateTime보다 빠르거나 Calendar.MaxSupportedDateTime보다 늦으면이 메서드는 ArgumentOutOfRangeException을 발생시킵니다.

앱의 현재 문화권은 무엇입니까?

+0

기본 en 문화권을 사용하고 있으며 미국 또는 GB를 지정하지 않았습니다. 그러나 기본 설정이 런던이나 미국 시간으로 전환되는지는 확실하지 않습니다. 현지화의 경우 앱 문화 선택이 전화 문화와 충돌하지 않도록하려면 어떻게해야합니까? 즉 그 순간에 일어나는 일인가? – user1477707

+0

그러나 나는 혼란 스럽다. 내 오류의 경우에 무엇이 날짜를 알려주고 있는가? 애플 리케이션이나 시스템에 애플 리케이션에 전화 에뮬레이터 또는 전화 에뮬레이터 애플 리케이션인가요? 어디에서 오류가 발생했으며 무엇이 불평하고 있습니까? – user1477707

1

내 앱이 현지화되어 있고 올바른 형식으로 문화 코드를 사용하지 않았습니다. 예를 들어 fr-FR 대신 ko-ko 또는 fr 대신 en을 사용합니다.

위에서 설명한대로 구체화되면 DateTime.Now.ToString()이 예상대로 작동하기 시작합니다.