Transfer The open resource correctly from the source in ArcGIS engine
AE in the MDB,SDE and other database operations, open but often can not release resources in a timely manner, resulting in other people operation prompt object is locked.
Many of the posts said a lot of principles, see also annoying and not practical, such as a summary of a sentence with System.Runtime.InteropServices.Marshal.ReleaseComObject (object O) Released, said very unclear, A lot of people have tried to get out of their sleep.
In fact, this is really the method, but the trick is to release several new AE objects gradually, such as:
Iworkspacefactory Fact = new Accessworkspacefactoryclass ();
Ifeatureworkspace Workspace = Fact.open (propset,0) as Ifeatureworkspace;
Ifeatureclass Fcls = Workspace.openfeatureclass ("District");
Ifeaturelayer Fly = new Featurelayerclass ();
......
IFeature PF
Ifield Pfield
......
The object is released at the end of the run, such as:
System.Runtime.InteropServices.Marshal.ReleaseComObject (Fact);
System.Runtime.InteropServices.Marshal.ReleaseComObject (Workspace);
System.Runtime.InteropServices.Marshal.ReleaseComObject (FCLS);
System.Runtime.InteropServices.Marshal.ReleaseComObject (Fly);
System.Runtime.InteropServices.Marshal.ReleaseComObject (PF);
System.Runtime.InteropServices.Marshal.ReleaseComObject (Pfield);
See, do not think you release the highest level of iworkspacefactory, iworkspace even if the finished. No way, AE is sometimes so difficult to understand the trouble.
Open resource is released correctly in ArcGIS engine