0

I write small WM 6.1 app which read and write to xml but i get the following exception:

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()

here is CreatDT method 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;
        }

any body help?

someone
  • 227
  • 6
  • 18

2 Answers2

0

if it's PlatformNotSupportedException then problem rely on a feature which does not exist in your system. Probably there are some Compact Framework components that are missing.

You can try selecting (unfortunately it's deselected on the picture) option marked below and see if it helps.

enter image description here

PawelZ
  • 117
  • 3
  • 13
0

Whether Type.GetType("System.String") does or does not cause you errors, I would recommend going with Alex's typeof(String) suggestion in the comments.

With that said, try placing a temporary try...catch block around the problematic routine to get a more detailed error message.

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

Who knows? "Key" could be a reserved word. You may have to go with something else, like "ID".

EDIT: I just noticed you supply a name for your DataTable: Setting. If that is some unallowed name value (like "Settings: $95 >> $110"), then your table may never get created.