diff --git a/src/coreclr/vm/gcheaputilities.cpp b/src/coreclr/vm/gcheaputilities.cpp index cd0259eef45d83..94564204f769b0 100644 --- a/src/coreclr/vm/gcheaputilities.cpp +++ b/src/coreclr/vm/gcheaputilities.cpp @@ -186,8 +186,12 @@ HMODULE LoadStandaloneGc(LPCWSTR libFileName, LPCWSTR libFilePath) return nullptr; } + // The APP_CONTEXT_BASE_DIRECTORY is always set by the host. In cases + // where the runtime is activated as a component, the base directory + // will be an empty string. If the base directory is an empty string, skip it. SString appBase; - if (HostInformation::GetProperty("APP_CONTEXT_BASE_DIRECTORY", appBase)) + if (HostInformation::GetProperty("APP_CONTEXT_BASE_DIRECTORY", appBase) + && u16_strlen(appBase.GetUnicode()) != 0) { PathString libPath = appBase.GetUnicode(); libPath.Append(libFileName);