I'm trying to add new feature to file GDB feature class and keep getting this error: Objects in this class cannot be updated outside an edit session. Feature class has attachments enabled (exists relationships). Googled alot about this problem and still can't figure it out. FYI I'm developing a standalone application. My code:
Public Shared Sub CreateFeature(ByVal workspace As IWorkspace, ByVal featureClass As IFeatureClass, ByVal point As ArcGIS.Geometry.IPoint, ByVal data As String)
Dim workspaceEdit As IWorkspaceEdit = CType(workspace, IWorkspaceEdit)
workspaceEdit.StartEditing(True)
workspaceEdit.StartEditOperation()
Dim featureBuffer As IFeatureBuffer = featureClass.CreateFeatureBuffer()
Dim featureCursor As IFeatureCursor = featureClass.Insert(True) ' <- at this point error occurs
Dim featureOID As Object
featureBuffer.Value(featureBuffer.Fields.FindField("Data")) = data
featureBuffer.Shape = point
featureOID = featureCursor.InsertFeature(featureBuffer)
featureCursor.Flush()
workspaceEdit.StopEditOperation()
workspaceEdit.StopEditing(True)
End Sub
-
What error are you getting? Did you try calling IFeatureClass.Insert(false) instead? Is this a standalone exe, if so are you initializing the license? What license level are you at? Can you successfully edit the featureclass with arcmap?Kirk Kuykendall– Kirk Kuykendall2013年03月24日 15:27:31 +00:00Commented Mar 24, 2013 at 15:27
-
The error is: Objects in this class cannot be updated outside an edit session. If I call IFeatureClass.Insert(false) I get the same error. This is a standalone exe and I am initializing the license on startup. I am at ArcInfo license (ArcGIS 10). I can edit the featureclass with ArcMap.DTT– DTT2013年03月25日 06:08:23 +00:00Commented Mar 25, 2013 at 6:08
-
Do you get an error with featureClass.CreateFeature(), then calling IFeature.Store() ?Kirk Kuykendall– Kirk Kuykendall2013年03月25日 13:20:01 +00:00Commented Mar 25, 2013 at 13:20
-
same problem with featureClass.CreateFeature(), then calling IFeature.Store()DTT– DTT2013年03月25日 14:22:20 +00:00Commented Mar 25, 2013 at 14:22
1 Answer 1
Figured it out. It was a license binding issue. I was using: ESRI.ArcGIS.RuntimeManager.BindLicense(ProductCode.Desktop)
instead of: ESRI.ArcGIS.RuntimeManager.BindLicense(ProductCode.Desktop, LicenseLevel.GeodatabaseUpdate)