2012-08-13 124 views
0

我寫的小WM 6.1的應用程序,其讀取和寫入XML,但我得到以下異常:的Windows Mobile 6 System.PlatformNotSupportedException

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方法體:

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; 
     } 

任何機構幫幫我?

+0

嘗試用'typeof(string)'替換Type.GetType(「System.String」)'(我沒有任何測試代碼的方法,只是猜測)。 – Alex 2012-08-13 12:43:33

+0

'typeof(string)'not working – someone 2012-08-13 13:12:01

+0

@PawelZ此選項已經檢查 – someone 2012-08-14 09:19:21

回答

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提供一個名稱:設置。如果這是一些不允許的名稱值(如「設置:$ 95 >> $ 110」),那麼您的表可能永遠不會被創建。