Tim,
Your implementation of Dispose isn't going to do anything. If anything,
you should be a little more diligent about the references that are being
passed around and calling ReleaseComObject on them when you are done (unless
this class has a member for a COM component which is not exposed outside the
class, in which case, you justwant to call ReleaseComObject in the Dispose
method).
That being said, you can try and call CoFreeUnusedLibraries through the
P/Invoke layer when you want to try and unload the COM dll.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
<Ti******@gmail.comwrote in message
news:11**********************@o80g2000hse.googlegr oups.com...
>I need to unload and load a COM DLL for multiple calls. The VC6 DLL's
are using static fileds which is causing me problems. I'm currently
implementing IDisposable using this as my Dispose method:
public void Dispose()
{
int referenceCount = 0;
do
{
referenceCount = Marshal.ReleaseComObject(obj);
}
while (referenceCount 0);
obj = null;
}
I confirmed that the method is being called. But I can still see the
COM DLL in memory after Dispose is run. The next time the COM DLL is
called, its still in memory which causes problems. Changing the
legicy VC6 is not an option.
Any ideas? Thanks in advance for your help.
Tim.