我写了一个小的WM 6.1应用程序,它读写xml但我得到以下异常:
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方法Body:
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 :(得分:0)
如果是PlatformNotSupportedException,则问题依赖于系统中不存在的功能。可能缺少一些Compact Framework组件。
您可以尝试选择(不幸的是,它已在图片中取消选中)选项,并查看是否有帮助。
答案 1 :(得分:0)
Type.GetType("System.String")
是否会导致错误,我建议您在评论中使用Alex 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;
}
谁知道? &#34;键&#34;可能是一个保留字。您可能必须使用其他内容,例如&#34; ID&#34;。
编辑:我刚刚注意到您为DataTable
提供了一个名称:设置。如果这是一些不允许的名称值(例如&#34;设置:$ 95&gt;&gt; $ 110&#34;),那么您的表可能永远不会被创建。