I have an out of process COM object that we are calling from C# using dllhost (we were unable to use COM+). This works great, and I have my own pool of objects that I can use whenever I want. The COM object will be reused many times and is long running (> 20 minutes sometimes). Unfortunately, this is an old VB ActiveX dll that occasionally hangs. So, I need to be able to kill it. I've tried releasing the COM object explicitly and then garbage collecting from another thread, but that does nothing. Does anyone have any ideas other than grabbing the PID of dllhost and killing that when I spin it up (probably not that safe)? Thanks for the help.
I've tried
System.Runtime.InteropServices.Marshal.ReleaseComObject(m_MyObj);
GC.Collect();
GC.WaitForPendingFinalizers();
m_MyObj = null;
and I create it by
uint hResult = Ole32Methods.CoCreateInstance(ref CalcServerGuid, null, (uint)CLSCTX.CLSCTX_LOCAL_SERVER, ref IID_IUnknown,
out CalcServerInstance);