From 085dbd413ed2b8a7e190c33d9d75a165d3c72104 Mon Sep 17 00:00:00 2001 From: Senthil Date: Wed, 30 Mar 2016 13:54:10 -0700 Subject: [PATCH] Expand LoadLibrary search paths --- src/corehost/common/pal.windows.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corehost/common/pal.windows.cpp b/src/corehost/common/pal.windows.cpp index fc03c40ed..c67c33c9a 100644 --- a/src/corehost/common/pal.windows.cpp +++ b/src/corehost/common/pal.windows.cpp @@ -85,7 +85,10 @@ bool pal::getcwd(pal::string_t* recv) bool pal::load_library(const char_t* path, dll_t* dll) { - *dll = ::LoadLibraryW(path); + // LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR: + // In portable apps, coreclr would come from another directory than the host, + // so make sure coreclr dependencies can be resolved from coreclr.dll load dir. + *dll = ::LoadLibraryExW(path, NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); if (*dll == nullptr) { trace::error(_X("Failed to load the dll from %s, HRESULT: 0x%X"), path, HRESULT_FROM_WIN32(GetLastError()));