Releasing feature class after using MakeFeatureLayer

393
3
11-12-2013 05:57 AM
Highlighted
Regular Contributor II
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
Reply
0 Kudos
3 Replies
Highlighted
Occasional Contributor
You might want to try forcing a garbage collect.
Reply
0 Kudos
Highlighted
MVP Frequent Contributor
Don't know if this will help but have a look at IGPUtilities.RemoveInternalLayer Method?
Reply
0 Kudos
Highlighted
Regular Contributor II
The IGPUtilities.RemoveInternalLayer  worked but even a better solution was to run the GP delete tool on the in memory layer.

Thanks
Mody
Reply
0 Kudos