<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: IWorkspaceEdit2 and FGDB - Objects in this class cannot be updated outside an edit session in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceedit2-and-fgdb-objects-in-this-class/m-p/1500994#M20661</link>
    <description>&lt;P&gt;It's been a long time and I may be wrong, but I think IFeatureClass.Update will not work on a versioned dataset.&lt;/P&gt;&lt;P&gt;You should be able to simply create a normal cursor on your QueryFilter.&amp;nbsp; The rest of the code should do your editing properly.&lt;/P&gt;&lt;P&gt;There is a chart on this help document:&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#IFeatureClass_Search.htm" target="_blank"&gt;https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#IFeatureClass_Search.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;that explains it more.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good Luck&lt;/P&gt;&lt;P&gt;Brent Hoskisson&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jul 2024 14:42:42 GMT</pubDate>
    <dc:creator>BrentHoskisson</dc:creator>
    <dc:date>2024-07-03T14:42:42Z</dc:date>
    <item>
      <title>IWorkspaceEdit2 and FGDB - Objects in this class cannot be updated outside an edit session</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceedit2-and-fgdb-objects-in-this-class/m-p/1500801#M20660</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Current software is ArcGIS 10.8.2 on Windows 10, application development with Visual Studio 2022.&lt;/P&gt;&lt;P&gt;I wrote a simple application for a one-time adaptation to a file geodatabase with feature linked annotations, to correct feature and annotation fields and positions. But it fails on &lt;STRONG&gt;IFeatureClass.Update()&lt;/STRONG&gt; with the error message '&lt;EM&gt;Objects in this class cannot be updated outside an edit session&lt;/EM&gt;', although an IWorkspaceEdit is used. It doesn't matter if the fgdb is on a network share or locally stored.&lt;BR /&gt;I do not need any graphical interface, so I can't test it with IMap, IMxApplication and IEditor.&lt;BR /&gt;Both featureclass and annotationclasses are in a the same featuredataset. I included only the featureclass in the code fragment.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;IFeatureWorkspace editableWorkspace;
string workspacePath = "c:\anyfolder\mygeodatabase.gdb";
 
using (ComReleaser comReleaser = new ComReleaser())
{
    object obj = new object();
    Type t = null;
    comReleaser.ManageLifetime(obj);
    t = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
    obj = Activator.CreateInstance(t);

    IWorkspaceFactory workspaceFactory = obj as FileGDBWorkspaceFactory;
    if (workspaceFactory != null)
    {
        editableWorkspace = workspaceFactory.OpenFromFile(workspacePath, 0) as IFeatureWorkspace;
    }
}

IFeatureDataset editableDataset = editableWorkspace.OpenFeatureDataset("mydataset");
IFeatureClass editableFeatureClass;
string featureClassName = "myfeatureclass";

if (editableDataset != null)
{
    IEnumDataset enumDataset = editableDataset.Subsets;
    enumDataset.Reset();
    IDataset currentDataset = enumDataset.Next();
    while (currentDataset != null)
    {
        if (currentDataset is IFeatureClass &amp;amp;&amp;amp; currentDataset.Name == featureClassName)
        {
            editableFeatureClass = currentDataset as IFeatureClass;
            break;
        }
 
        currentDataset = enumDataset.Next();
    }
}

IWorkspaceEdit2 workspaceEdit;
workspaceEdit = editableWorkspace as IWorkspaceEdit2;
workspaceEdit.StartEditing(false);

if (workspaceEdit.IsBeingEdited())
{
    workspaceEdit.StartEditOperation();
 
    if (workspaceEdit.IsInEditOperation)
    {
		IQueryFilter filter = new QueryFilter { WhereClause = "OBJECTID = 1" };
		IFeatureCursor cursor = editableFeatureClass.Update(filter, false); // throws error
		if (cursor != null)
		{
			IFeature feature = cursor.NextFeature();
			if (feature != null)
			{
				feature.set_Value(3, "mytext");
				feature.Store();
			}
		}
		Marshal.ReleaseComObject(cursor);

		workspaceEdit.StopEditOperation();
	}
	
	workspaceEdit.StopEditing(true);
}&lt;/LI-CODE&gt;&lt;P&gt;I can read the fgdb in C# and also edit it in ArcMap. Must doing something wrong, but can't see it.&lt;/P&gt;&lt;P&gt;Many thank for helping,&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Pieter&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2024 07:20:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceedit2-and-fgdb-objects-in-this-class/m-p/1500801#M20660</guid>
      <dc:creator>PieterLinks</dc:creator>
      <dc:date>2024-07-03T07:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspaceEdit2 and FGDB - Objects in this class cannot be updated outside an edit session</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceedit2-and-fgdb-objects-in-this-class/m-p/1500994#M20661</link>
      <description>&lt;P&gt;It's been a long time and I may be wrong, but I think IFeatureClass.Update will not work on a versioned dataset.&lt;/P&gt;&lt;P&gt;You should be able to simply create a normal cursor on your QueryFilter.&amp;nbsp; The rest of the code should do your editing properly.&lt;/P&gt;&lt;P&gt;There is a chart on this help document:&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#IFeatureClass_Search.htm" target="_blank"&gt;https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#IFeatureClass_Search.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;that explains it more.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good Luck&lt;/P&gt;&lt;P&gt;Brent Hoskisson&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2024 14:42:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceedit2-and-fgdb-objects-in-this-class/m-p/1500994#M20661</guid>
      <dc:creator>BrentHoskisson</dc:creator>
      <dc:date>2024-07-03T14:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspaceEdit2 and FGDB - Objects in this class cannot be updated outside an edit session</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceedit2-and-fgdb-objects-in-this-class/m-p/1501003#M20662</link>
      <description>&lt;P&gt;P.S. you might want to put your Cursor.NextFeature in a while loop to edit all of the cursor items.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IFeature feature;&lt;/P&gt;&lt;P&gt;while ((feature = cursor.NextFeature()) != null)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brent Hoskisson&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2024 14:57:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceedit2-and-fgdb-objects-in-this-class/m-p/1501003#M20662</guid>
      <dc:creator>BrentHoskisson</dc:creator>
      <dc:date>2024-07-03T14:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspaceEdit2 and FGDB - Objects in this class cannot be updated outside an edit session</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceedit2-and-fgdb-objects-in-this-class/m-p/1501461#M20663</link>
      <description>&lt;P&gt;As far as I know the datasets in this file geodatabase are not versioned. When I try to 'register as versioned' one of the datasets, I get this error:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;000133 : The dataset cannot be versioned.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;There could be a schema lock on the dataset. The dataset must be registered with the geodatabase. The dataset cannot support versioning.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The file geodatabase was created in 2012 with ArcGIS and migrated to 10 in time. There was and is no need for versioning.&lt;/P&gt;&lt;P&gt;I did a lot of editing other file geodatabases the same way (with IWorkspaceEdit2) without any problem, but this particular one refuses.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jul 2024 07:36:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspaceedit2-and-fgdb-objects-in-this-class/m-p/1501461#M20663</guid>
      <dc:creator>PieterLinks</dc:creator>
      <dc:date>2024-07-04T07:36:00Z</dc:date>
    </item>
  </channel>
</rss>

