2012-08-13 3 views
0

본인은 XML로 쓰기 그러나 나는 다음과 같은 예외가 작은 WM 6.1 응용 프로그램을 쓰기 :윈도우 모바일 6 System.PlatformNotSupportedException

public static DataTable CreateDT(string Setting, string Key, string Value) 
     { 
      DataTable dt; 
      dt = new DataTable(Setting); 
      dt.Columns.Add("Key", Type.GetType("System.String")); //<-- error here 
      dt.Columns.Add("Value", Type.GetType("System.String")); 
      AddRow(ref dt, Key, Value); 
      return dt; 
     } 

어떤 신체 : 여기

System.PlatformNotSupportedException was unhandled 
    Message="PlatformNotSupportedException" 
    StackTrace: 
     at System.Globalization.CompareInfo..ctor(Int32 culture) 
     at System.Globalization.CompareInfo.GetCompareInfo(Int32 culture) 
     at System.Globalization.CultureInfo.get_CompareInfo() 
     at System.CultureAwareComparer..ctor(CultureInfo culture, Boolean ignoreCase) 
     at System.StringComparer.Create(CultureInfo culture, Boolean ignoreCase) 
     at System.Data.DataTable.GetSpecialHashCode(String name) 
     at System.Data.DataColumnCollection.RegisterColumnName(String name, DataColumn column, DataTable table) 
     at System.Data.DataColumnCollection.BaseAdd(DataColumn column) 
     at System.Data.DataColumnCollection.AddAt(Int32 index, DataColumn column) 
     at System.Data.DataColumnCollection.Add(DataColumn column) 
     at System.Data.DataColumnCollection.Add(String columnName, Type type) 
     at MyApp.Settings.CreateDT(String Setting, String Key, String Value) 
     at MyApp.Program.Main() 

이 CreatDT 방법 ​​몸이다 도움?

+0

'Type.GetType ("System.String")을'typeof (string)'으로 바꾸어보십시오. (코드를 테스트 할 방법이 없으므로 그냥 짐작할 수 있습니다.) – Alex

+0

'typeof (string)'도 작동하지 않습니다 – someone

+0

@PawelZ이 옵션이 이미 선택되어 있습니다. – someone

답변

0

PlatformNotSupportedException 인 경우 문제는 시스템에없는 기능에 의존합니다. 아마도 Compact Framework 구성 요소 중 일부가 누락되었을 수 있습니다.

아래에 표시된 옵션을 선택 (불행히도 사진에서 선택 취소)하고 도움이되는지 확인해보십시오.

enter image description here

0

여부 Type.GetType("System.String") 나는 코멘트에 알렉스의 typeof(String) 제안에가는 것이 좋습니다, 않습니다 또는 당신에게 오류가 발생하지 않습니다.

그런 말로 문제의 루틴을 둘러싼 임시 try ... catch 블록을 배치하여보다 자세한 오류 메시지를 얻으십시오.

public static DataTable CreateDT(string Setting, string Key, string Value) 
{ 
    DataTable dt = new DataTable(Setting); 
    try { 
    dt.Columns.Add("Key", typeof(String)); //<-- error here 
    dt.Columns.Add("Value", typeof("String")); 
    AddRow(ref dt, Key, Value); 
    } catch (Exception err) { 
    MessageBox.Show(err.Message); 
    if (err.InnerException != null) { 
     MessageBox.Show(err.InnerException.Message); 
    } 
    } 
    return dt; 
} 

누가 알겠습니까? "키"는 예약어 일 수 있습니다. "ID"와 같은 다른 것을 사용해야 할 수도 있습니다.

편집 : 설정 : 난 그냥 당신이 당신이 DataTable의 이름을 제공 발견. 그것이 ("Settings : $ 95 >> $ 110"과 같이) 허용되지 않는 이름 값이라면 테이블을 만들지 못할 수도 있습니다.