Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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  
share|improve this question
    
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 Mar 24 '13 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 Mar 25 '13 at 6:08
    
Do you get an error with featureClass.CreateFeature(), then calling IFeature.Store() ? –  Kirk Kuykendall Mar 25 '13 at 13:20
    
same problem with featureClass.CreateFeature(), then calling IFeature.Store() –  DTT Mar 25 '13 at 14:22
add comment

1 Answer 1

up vote 0 down vote accepted

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)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.