IFieldsEdit fldsE = pFc.Fields as IFieldsEdit; IField fld = new FieldClass(); IFieldEdit2 fldE = fld as IFieldEdit2; fldE.Type_2 = esriFieldType.esriFieldTypeString; fldE.Name_2 = "XXX"; pClass.AddField(fld);
再次执行 成功!
AddField is used when creating a fields collection and cannot be used to insert a field into a fields collection belonging to an existing table. To add a field to an existing object class, use the IClass::AddField method. 意思就是说如果修改的是当前已经存在的表或者要数类的字段,那么你就使用IClass::AddField方法生成字段