We use a third party COM component, which seems to have
troubles of
closing its files. I called Marshal.FinalReleaseComObject to
release
the COM object asap when I am done with it, but it still
seems to leak
its open files...
Contacted support and this is what they came with:
//-----------
//might be a bit overly explicit but a WeakReference will
not survive
//a garbage collection
WeakReference wkref = new WeakReference(comRef); comRef =
null;
GC.Collect(GC.GetGeneration(wkref));
//-----------
To me this seemed nonsense (the use of WeakRef), so I
altered the code into
int generation = GC.GetGeneration(comRef);
Marshal.FinalReleaseComObject(comRef);
comRef = null;
GC.Collect(generation);
but still, the com object is leaking its files...
Contacted support again, and they really want me to use code
sample
with the WeakReference...
I was about to send them an harsh email, but counted till 10
and typed
this email...
Would the use of WeakReference actually make any difference?
I dont
think so, but maybe I am wrong...
// Ryan
===================================
This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|