| 
 | 
 
刚刚接触mapx,在网上找到的代码 
        private void button1_Click(object sender, EventArgs e) 
        { 
            MapXLib.LayerInfoClass li = new MapXLib.LayerInfoClass(); 
            MapXLib.Features ftrs = null; 
            MapXLib.FieldsClass flds = new MapXLib.FieldsClass(); 
            MapXLib.Fields Myflds = null; 
            MapXLib.Dataset dts = null; 
            flds.Add("State", "State_Name", MapXLib.AggregationFunctionConstants.miAggregationSum, MapXLib.FieldTypeConstants.miTypeString); 
            dts = axMap1.DataSets.Add(MapXLib.DatasetTypeConstants.miDataSetLayer, axMap1.Layers._Item(1), "MyLayer", 0, 0, 0, flds, false); 
            Myflds = dts.Fields; 
            ftrs = axMap1.Layers._Item("USA").Selection.Clone(); 
            li.Type = MapXLib.LayerInfoTypeConstants.miLayerInfoTypeTemp; 
            li.AddParameter("Name", "USA Temp Layer"); 
            li.AddParameter("Fields", Myflds); 
            li.AddParameter("Features", ftrs); 
            axMap1.Layers.Add(li, 1); 
            axMap1.Layers.LayersDlg("", ""); 
        } 
  
为什么我每次运行到   dts = axMap1.DataSets.Add(MapXLib.DatasetTypeConstants.miDataSetLayer, axMap1.Layers._Item(1), "MyLayer", 0, 0, 0, flds, false);这一句就弹出错误呢。 
错误信息: 
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll 
Additional information: No object was found using the index you specified.  |   
 
 
 
 |