From 97942293086e18e849b0cbd4e7c7dc22d765a4f4 Mon Sep 17 00:00:00 2001 From: Aaron R Robinson Date: Tue, 23 Sep 2025 10:07:39 -0700 Subject: [PATCH] Load Standalone GC correctly in component scenarios. --- src/coreclr/vm/gcheaputilities.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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);