AnsweredAssumed Answered

IFieldsEdit.AddField no longer works

Question asked by dryter on Mar 3, 2016

I built an addin in vb.net for 10.2 with VS2010. I upgraded to 10.3.1 and VS2012, fixed the target files, and switched references to COM. I'm using Framework 4.0. Almost all functionality of the addin works, but now IFieldsEdit doesn't seem to be the same interface. Some of the properties and events described in the API reference no longer exist, and AddField doesn't work. I've seen some other questions about this but haven't seen anything that fixes my situation. Here is the part of the code that crashes. AddField isn't listed as an event, but I put it in anyway. This worked fine before changing to 10.3.1 and 2012.

 

Imports ESRI.ArcGIS.Geodatabase

...

            ' Create a fields collection for the feature class.

            Dim pIOCD As IObjectClassDescription = New ObjectClassDescription

            Dim fields As IFields = pIOCD.RequiredFields

            Dim fieldsEdit As IFieldsEdit = CType(fields, IFieldsEdit)

            ' Add an ObjectID field to the fields collection. This is mandatory for feature classes.

            Dim pFld As IField2 = New Field

            AddField("OID", esriFieldType.esriFieldTypeOID, pFld) 'sub that edits the field

            fieldsEdit.AddField(pFld)    <=== crashes here: "Exception from HRESULT:0x80040705"

 

I appreciate any help on this. This addin has a lot of code and this is the only interface that I have noticed a problem with.

Outcomes