Releasing feature class after using MakeFeatureLayer

596
3
11-12-2013 05:57 AM
ModyBuchbinder
Esri Regular Contributor
I am using ArcObjects to call GP tools.
Most tools does not leave any locks and the data can be deleted after the tool is done.
The MakeFeatureLayer is different. It gets a feature class and return a string so there is no COM object I can release.
I did release the feature class and the workspace but the feature class is still locked.
I tried to cast the IGeoProcessorResult.getOutput into ILayer so I can release it but it fail.
I know I can get the feature class using DecodeFeatureLayer but it does not help me to clean up.
I am using MakeFeatureLayer, do something with that layer and then would like to delete the feature class.

Please help
0 Kudos
3 Replies
JohnStephens
Occasional Contributor
You might want to try forcing a garbage collect.
0 Kudos
DuncanHornby
MVP Notable Contributor
Don't know if this will help but have a look at IGPUtilities.RemoveInternalLayer Method?
0 Kudos
ModyBuchbinder
Esri Regular Contributor
The IGPUtilities.RemoveInternalLayer  worked but even a better solution was to run the GP delete tool on the in memory layer.

Thanks
Mody
0 Kudos