<?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: AddSpatialIndex fails with ERROR 000464 after Project.Current.SaveEditsAsync() for shapefile (ArcGIS Pro SDK 3.x) in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addspatialindex-fails-with-error-000464-after/m-p/1681671#M13429</link>
    <description>&lt;P&gt;Hi Aashis,&lt;/P&gt;&lt;P&gt;I tried modifying the code as follows:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var saved = Project.Current.SaveEditsAsync().GetAwaiter().GetResult();
if (!saved)
{
    // throw exception
}
await CheckUtility.RebuildSpatialIndexAndRefreshLayerAsync(
    new FeatureLayer[] { logLayer }, logFile, currentWorkspace);&lt;/LI-CODE&gt;&lt;P&gt;However, the same &lt;STRONG&gt;464 error&lt;/STRONG&gt; still occurs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since rebuilding a spatial index for a &lt;STRONG&gt;shapefile&lt;/STRONG&gt; (especially for a temporary / log feature class) is not always strictly required, I am planning to handle this case as follows:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If a 464 error occurs during spatial index rebuilding for a specific feature class (e.g. a log or temporary layer),&lt;/LI&gt;&lt;LI&gt;Treat it as non-fatal and continue processing.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This approach allows the main processing to proceed without being blocked by a schema lock on non-essential data.&lt;/P&gt;&lt;P&gt;Thank you very much for your suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Feb 2026 01:29:48 GMT</pubDate>
    <dc:creator>rdc_hirohara</dc:creator>
    <dc:date>2026-02-03T01:29:48Z</dc:date>
    <item>
      <title>AddSpatialIndex fails with ERROR 000464 after Project.Current.SaveEditsAsync() for shapefile (ArcGIS Pro SDK 3.x)</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addspatialindex-fails-with-error-000464-after/m-p/1681362#M13423</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Environment:&lt;/STRONG&gt;&lt;BR /&gt;- ArcGIS Pro 3.3&lt;BR /&gt;- ArcGIS Pro SDK for .NET&lt;BR /&gt;- C# Add-in&lt;BR /&gt;- Target data: Shapefile (.shp)&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt;&lt;BR /&gt;In an ArcGIS Pro add-in, I sometimes get the following error when trying to run management.AddSpatialIndex on a shapefile immediately after saving edits:&lt;BR /&gt;ERROR 000464: Cannot get exclusive schema lock.&lt;BR /&gt;Another application or service is editing or using this data.&lt;BR /&gt;(ErrorCode = 464)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This happens even though:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;The shapefile is only used inside the same ArcGIS Pro session&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;All FeatureClass / Row / Cursor objects are properly disposed (using)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;No other application is accessing the shapefile&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Interestingly, &lt;STRONG&gt;right after this error occurs&lt;/STRONG&gt;, I can manually run &lt;EM&gt;Add Spatial Index&lt;/EM&gt;&lt;BR /&gt;from the Geoprocessing UI on the same shapefile, and it succeeds without any problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Typical flow (simplified)&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;await Project.Current.SaveEditsAsync();

// Immediately after SaveEditsAsync
await Geoprocessing.ExecuteToolAsync(
    "management.AddSpatialIndex",
    Geoprocessing.MakeValueArray(shapefilePath)
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Observations&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;The error does &lt;STRONG&gt;not always reproduce&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;It is more likely to happen:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Right after starting ArcGIS Pro&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Or early in the day (first execution)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Adding a delay (e.g. Task.Delay(200~400ms)) reduces the frequency,&lt;BR /&gt;but does not completely eliminate the issue&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;File Geodatabase / Enterprise Geodatabase do &lt;STRONG&gt;not&lt;/STRONG&gt; show this problem&lt;BR /&gt;(only shapefiles)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My understanding&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;It looks like Project.Current.SaveEditsAsync() returns before all internal&lt;BR /&gt;locks related to shapefiles are fully released, and&lt;BR /&gt;AddSpatialIndex requires an &lt;STRONG&gt;exclusive schema lock&lt;/STRONG&gt;, which sometimes cannot&lt;BR /&gt;be obtained immediately after saving edits.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Questions&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;Is this a known behavior/limitation when using shapefiles with&lt;BR /&gt;SaveEditsAsync() + geoprocessing tools?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Is there a recommended or supported way to:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Wait until the schema lock is fully released?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Or reliably detect that it is safe to run AddSpatialIndex?&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Is using a retry / delay loop the only practical workaround?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Has this behavior changed or improved in newer versions of ArcGIS Pro / SDK?&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Any guidance or best practices would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Feb 2026 02:32:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/addspatialindex-fails-with-error-000464-after/m-p/1681362#M13423</guid>
      <dc:creator>rdc_hirohara</dc:creator>
      <dc:date>2026-02-02T02:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: AddSpatialIndex fails with ERROR 000464 after Project.Current.SaveEditsAsync() for shapefile (ArcGIS Pro SDK 3.x)</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addspatialindex-fails-with-error-000464-after/m-p/1681363#M13424</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Additional note:&lt;/STRONG&gt;&lt;BR /&gt;The error can occur even when all FeatureClass / Row / Cursor objects&lt;BR /&gt;are properly disposed using 'using' blocks.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Feb 2026 02:34:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/addspatialindex-fails-with-error-000464-after/m-p/1681363#M13424</guid>
      <dc:creator>rdc_hirohara</dc:creator>
      <dc:date>2026-02-02T02:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: AddSpatialIndex fails with ERROR 000464 after Project.Current.SaveEditsAsync() for shapefile (ArcGIS Pro SDK 3.x)</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addspatialindex-fails-with-error-000464-after/m-p/1681507#M13428</link>
      <description>&lt;P&gt;&lt;SPAN&gt;As a workaround, can you convert line #1 to Project.Current.SaveEditsAsync().Wait(), which converts asynchronous code to synchronous by blocking the main thread until the task is completed&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Feb 2026 16:35:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/addspatialindex-fails-with-error-000464-after/m-p/1681507#M13428</guid>
      <dc:creator>Aashis</dc:creator>
      <dc:date>2026-02-02T16:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: AddSpatialIndex fails with ERROR 000464 after Project.Current.SaveEditsAsync() for shapefile (ArcGIS Pro SDK 3.x)</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addspatialindex-fails-with-error-000464-after/m-p/1681671#M13429</link>
      <description>&lt;P&gt;Hi Aashis,&lt;/P&gt;&lt;P&gt;I tried modifying the code as follows:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var saved = Project.Current.SaveEditsAsync().GetAwaiter().GetResult();
if (!saved)
{
    // throw exception
}
await CheckUtility.RebuildSpatialIndexAndRefreshLayerAsync(
    new FeatureLayer[] { logLayer }, logFile, currentWorkspace);&lt;/LI-CODE&gt;&lt;P&gt;However, the same &lt;STRONG&gt;464 error&lt;/STRONG&gt; still occurs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since rebuilding a spatial index for a &lt;STRONG&gt;shapefile&lt;/STRONG&gt; (especially for a temporary / log feature class) is not always strictly required, I am planning to handle this case as follows:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If a 464 error occurs during spatial index rebuilding for a specific feature class (e.g. a log or temporary layer),&lt;/LI&gt;&lt;LI&gt;Treat it as non-fatal and continue processing.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This approach allows the main processing to proceed without being blocked by a schema lock on non-essential data.&lt;/P&gt;&lt;P&gt;Thank you very much for your suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2026 01:29:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/addspatialindex-fails-with-error-000464-after/m-p/1681671#M13429</guid>
      <dc:creator>rdc_hirohara</dc:creator>
      <dc:date>2026-02-03T01:29:48Z</dc:date>
    </item>
  </channel>
</rss>

