ERROR
Looping through a recordset using IFeatureCursor may cause the following error:
"Layer in Use- Maximum number of streams exceeded"
Garbage collection takes care of releasing resources in managed code. This process is non-deterministic and will release resources at some undetermined time. In most cases this approach works fine, however in this situation it is necessary to mark the COM object as eligible for garbage collection so the resources will be released in a timely manner.
Code:
C#:
using System.Runtime.InteropServices;
VB.Net:
Imports System.Runtime.InteropServices
Code:
Marshal.ReleaseComObject(pFeatCursor)
Get help from ArcGIS experts
Download the Esri Support App