From 276d202e792d78c1298795fa72a95c47a182160a Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Thu, 28 Feb 2013 15:43:25 -0600 Subject: [PATCH] mscoree: Keep a reference to mscoree when shutting down. --- dlls/mscoree/metahost.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dlls/mscoree/metahost.c b/dlls/mscoree/metahost.c index 143494c19e..690607545b 100644 --- a/dlls/mscoree/metahost.c +++ b/dlls/mscoree/metahost.c @@ -313,6 +313,12 @@ static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost * void unload_all_runtimes(void) { int i; + HMODULE handle; + + /* If the only references to mscoree are through dll's that were loaded by + * Mono, shutting down the Mono runtime will free mscoree, so take a + * reference to prevent that from happening. */ + GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const WCHAR *)&unload_all_runtimes, &handle); for (i=0; i