sparadesi

Objects in this class cannot be updated outside of an edit session[NE.EQUIPMENT]

Discussion created by sparadesi on Jun 3, 2011
Latest reply on Dec 13, 2011 by chane0
Hi All,

In need of urgent help.

I am trying to update a featureclass without help of IMap and IDocument. But i am repeateadly getting an error saying 'Objects in this class cannot be updated outside of an edit session[NE.EQUIPMENT]'. Please see the below code and let me is this possible or let me know an alternative. My general concept is not to use IMap or IDocument.

I am using
ArcGIS Desktop 9.3
Visual studio 2010(C#).


ESRI.ArcGIS.esriSystem.IAoInitialize arcLicense = new ESRI.ArcGIS.esriSystem.AoInitialize();
                ESRI.ArcGIS.esriSystem.IPropertySet PSC = new ESRI.ArcGIS.esriSystem.PropertySetClass();

                arcLicense.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcView);

                PSC.SetProperty("SERVER", "1.1.1.1");
                PSC.SetProperty("INSTANCE", "1111");
                PSC.SetProperty("USER", "QA");
                PSC.SetProperty("PASSWORD", "******");
                PSC.SetProperty("DATABASE", "TESTDB");
                PSC.SetProperty("VERSION", "SDE.DEFAULT");
                ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory();
                ESRI.ArcGIS.Geodatabase.IWorkspace workspace = workspaceFactory.Open(PSC, 0);
                ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;

               
               IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspace;
                IVersion qaVersion = versionedWorkspace.FindVersion("SDE.DEFAULT"); //APATEL.NEW WO   SDE.DEFAULT
                ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = ((IFeatureWorkspace)qaVersion).OpenFeatureClass("NE.EQUIPMENT");

                IMultiuserWorkspaceEdit muWorkspaceEdit = (IMultiuserWorkspaceEdit)workspace;
                IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)qaVersion;

                // Start a versioned edit session and an edit operation.
                muWorkspaceEdit.StartMultiuserEditing
                  (esriMultiuserEditSessionMode.esriMESMVersioned);
                workspaceEdit.StartEditing(false);
                workspaceEdit.StartEditOperation();
                if (workspaceEdit.IsBeingEdited())
                {
                    IFeatureBuffer buffFeature = featureClass.CreateFeatureBuffer();
                    IFeatureCursor cur = featureClass.Insert(true);
                }
                workspaceEdit.StopEditing(true);               

                muWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);

                IFeatureBuffer newFeature = featureClass.CreateFeatureBuffer();
                newFeature.Shape = oldFeature.ShapeCopy;
                featureClass.Insert(false);//getting exception here "Objects in this class cannot be updated outside an edit session [NE.EQUIPMENT]"

                workspaceEdit.StopEditing(true);

Please let me know if i need to provide any further information.

Thank you very much in advance.

Regards,
Srinivasa.

Outcomes