Objects in this class cannot be updated outside an edit session

4385
3
11-28-2012 12:13 PM
JohnCassarow
New Contributor
System.Runtime.InteropServices.COMException (0x80041354): Objects in this class cannot be updated outside an edit session [test.TEST.SECTIONDATA]
   at ESRI.ArcGIS.Geodatabase.ITable.CreateRow()
   at StreamAnalyst_AGS10.frmXSInspector.AddSurvey()

I am getting this error using an custom extension built in .net using in ArcGIS 10, the error only appears when pointed to an SDE database and not a filegeodatabase.
0 Kudos
3 Replies
JustinHunter
New Contributor III
This sounds similar to the issue I was having, but I cannot be sure. Either way, my code below.

IMapServer3 ms = (IMapServer3)this.mapServerDataAccess;
IDataset fc = this.mapServerDataAccess.GetDataSource(ms.DefaultMapName, 0) as IDataset;
IFeatureWorkspace workspace = (IFeatureWorkspace)fc.Workspace;
IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)fc.Workspace;
workspaceEdit.StartEditing(false);
workspaceEdit.StartEditOperation();
IFeatureClass fClass = workspace.OpenFeatureClass(layer);

IFeature feature = fClass.CreateFeature();
// Removed lines where assigning data to the feature...
feature.Store();

workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);


Hope it helps!
0 Kudos
JulianGomez
New Contributor II

Please note that if your featureclass contains attachments and you're in SDE, you'll have to use an additional ArcObject: IMultiuserWorkspaceEdit

0 Kudos
SamiEria
New Contributor III

This error message is associated with a number of possible causes. Here are two reasons:

1- If your SDE data is not versioned. In this case, simply register your data as versioned using ArcCatalog.

2- If you connected to your SDE geodatabase programmatically using IPropertySet, and the server name used is an alias name instead of the original server name. Use the IPropertySet.GetAll properties() method to investigate the exact names of all the properties you would need to supply to the IPropertySet. It is easier to simply connect via the SDE connection file.

For detailed information about creating features and Managing Edit Sessions using ArcObjects, please view the following documentation in the ArcObjects Help:

Creating Features

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Creating_features/00010000049v00...

Managing Editing Sessions and Edit Operations

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Managing_edit_sessions_and_edit_... 

0 Kudos