private void Dispose()
{
if (gcHandle.IsAllocated)
gcHandle.Free();
if (comInterface != IntPtr.Zero)
{
Marshal.FreeHGlobal(comInterface);
comInterface = IntPtr.Zero;
}
managedInterface = null;
lock (managedVtable)
{
// Dispose vtable when shutting down
if (--vtableRefCount == 0 && Environment.HasShutdownStarted)
DisposeVtable();
}
}