tomaszb

Problem with FeatureClassDescription in ArcObjects 10, C#

Discussion created by tomaszb on Apr 29, 2011
Latest reply on Apr 29, 2011 by tomaszb
I have a problem while creating FeatureClassDescription from a feature class. I use following code:

        IMxDocument iDoc = ArcMap.Application.Document as IMxDocument;
        IMap mainMap = iDoc.Maps.get_Item(0);
        zoneLayer = mainMap.get_Layer(0);
        IFeatureLayer zFLayer = zoneLayer as IFeatureLayer;
        IFeatureClass zonesClass1 = zFLayer.FeatureClass;
        IFeatureClassDescriptor zoneDescriptor = new FeatureClassDescriptionClass() as IFeatureClassDescriptor;
        IFields zFields = zonesClass1.Fields;
        IField zField = zFields.get_Field(3);
        try
            {
                zoneDescriptor.Create(zonesClass1, null, zField.Name);
            }
        catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


And it throw an exception during zoneDescriptor.Create(). I have tried it with many different feature classses and different types of fields and with querry filters, but its allways thesame...

Thanks for help.
Tomasz

Outcomes