diff --git a/src/vm/dllimportcallback.cpp b/src/vm/dllimportcallback.cpp index b5a4c9c4d751..8c4970970bf4 100644 --- a/src/vm/dllimportcallback.cpp +++ b/src/vm/dllimportcallback.cpp @@ -961,11 +961,18 @@ void UMEntryThunk::Terminate() CONTRACTL { NOTHROW; + MODE_ANY; } CONTRACTL_END; m_code.Poison(); + if (GetObjectHandle()) + { + DestroyLongWeakHandle(GetObjectHandle()); + m_pObjectHandle = 0; + } + s_thunkFreeList.AddToList(this); } diff --git a/src/vm/dllimportcallback.h b/src/vm/dllimportcallback.h index 3d93d3263bb6..03be244e54b4 100644 --- a/src/vm/dllimportcallback.h +++ b/src/vm/dllimportcallback.h @@ -310,22 +310,6 @@ class UMEntryThunk #endif } - ~UMEntryThunk() - { - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - if (GetObjectHandle()) - { - DestroyLongWeakHandle(GetObjectHandle()); - } - } - void Terminate(); VOID RunTimeInit()