Featureclasses with attachments: objects cannot be updated outside edit session

المشرف العام

Administrator
طاقم الإدارة
I am writing an ArcMap add-in using C# with Visual Studio 2010 and ArcGIS 10.1. I want to add features to a featureclass in an Enterprise Geodatabase (ArcGIS Server 10.1 on SQL Server). This is my code:

var mapLayers = GetAllLayersFromMap(); if (mapLayers.Count > 0) { IWorkspace workspace = ((IDataset)mapLayers[0]).Workspace; IFeatureWorkspace fWorkspace = workspace as IFeatureWorkspace; IWorkspaceEdit workspaceEdit = fWorkspace as IWorkspaceEdit; workspaceEdit.StartEditing(false); workspaceEdit.StartEditOperation(); ILayer layerPunt = mapLayers[0] as ILayer; IFeatureLayer featureLayer = layerPunt as IFeatureLayer; IFeatureClass punten = featureLayer.FeatureClass; IFeatureBuffer bufferPunten = punten.CreateFeatureBuffer(); IFeatureCursor cursorPunten = punten.Insert(true); workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); } When I load a featureclass that has no attachments it works fine. If I create attachments to the same featureclass and try again, it fails. The code crashes on the line where the insert cursor is created: "Objects in this class cannot be edited outside an edit session". When I delete the attachments from the featureclass it works again.

If I start an edit session from ArcMap through the Editor toolbar, I can edit featureclasses with attachments (btw: this proves that the licensing level is ok). So I tried starting the edit session from code through the IEditor interface. It fails on the same line with a COM Exception.

Ideas anyone?



أكثر...
 
أعلى