Merge branch 'release/3.0-preview8' into release/3.0
This commit is contained in:
commit
0574a3fc94
|
|
@ -30,16 +30,17 @@ void HostFxrErrorRedirector::HostFxrErrorRedirectorCallback(const WCHAR* message
|
||||||
m_writeFunction->Append(std::wstring(message) + L"\r\n");
|
m_writeFunction->Append(std::wstring(message) + L"\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostFxr::Load()
|
|
||||||
{
|
|
||||||
HMODULE hModule;
|
|
||||||
THROW_LAST_ERROR_IF(!GetModuleHandleEx(0, L"hostfxr.dll", &hModule));
|
|
||||||
Load(hModule);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HostFxr::Load(HMODULE moduleHandle)
|
void HostFxr::Load(HMODULE moduleHandle)
|
||||||
{
|
{
|
||||||
|
// A hostfxr may already be loaded here if we tried to start with an
|
||||||
|
// invalid configuration. Release hostfxr before loading it again.
|
||||||
|
if (m_hHostFxrDll != nullptr)
|
||||||
|
{
|
||||||
|
m_hHostFxrDll.release();
|
||||||
|
}
|
||||||
|
|
||||||
m_hHostFxrDll = moduleHandle;
|
m_hHostFxrDll = moduleHandle;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_hostfxr_get_native_search_directories_fn = ModuleHelpers::GetKnownProcAddress<hostfxr_get_native_search_directories_fn>(moduleHandle, "hostfxr_get_native_search_directories");
|
m_hostfxr_get_native_search_directories_fn = ModuleHelpers::GetKnownProcAddress<hostfxr_get_native_search_directories_fn>(moduleHandle, "hostfxr_get_native_search_directories");
|
||||||
|
|
@ -63,9 +64,13 @@ void HostFxr::Load(HMODULE moduleHandle)
|
||||||
|
|
||||||
void HostFxr::Load(const std::wstring& location)
|
void HostFxr::Load(const std::wstring& location)
|
||||||
{
|
{
|
||||||
|
// Make sure to always load hostfxr via an absolute path.
|
||||||
|
// If the process fails to start for whatever reason, a mismatched hostfxr
|
||||||
|
// may be already loaded in the process.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HMODULE hModule;
|
HMODULE hModule;
|
||||||
|
LOG_INFOF(L"Loading hostfxr from location %s", location.c_str());
|
||||||
THROW_LAST_ERROR_IF_NULL(hModule = LoadLibraryW(location.c_str()));
|
THROW_LAST_ERROR_IF_NULL(hModule = LoadLibraryW(location.c_str()));
|
||||||
Load(hModule);
|
Load(hModule);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Load();
|
|
||||||
void Load(HMODULE moduleHandle);
|
void Load(HMODULE moduleHandle);
|
||||||
void Load(const std::wstring& location);
|
void Load(const std::wstring& location);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ IN_PROCESS_APPLICATION::ExecuteApplication()
|
||||||
|
|
||||||
hostFxrResolutionResult->GetArguments(context->m_argc, context->m_argv);
|
hostFxrResolutionResult->GetArguments(context->m_argc, context->m_argv);
|
||||||
THROW_IF_FAILED(SetEnvironmentVariablesOnWorkerProcess());
|
THROW_IF_FAILED(SetEnvironmentVariablesOnWorkerProcess());
|
||||||
context->m_hostFxr.Load();
|
context->m_hostFxr.Load(hostFxrResolutionResult->GetHostFxrLocation());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue