diff --git a/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs b/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs index d39f92cf..2b69cd07 100644 --- a/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs +++ b/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs @@ -230,8 +230,11 @@ namespace Microsoft.SqlTools.Extensibility var apiApplicationFileInfo = new FileInfo($"{folderPath}{Path.DirectorySeparatorChar}{assemblyName.Name}.dll"); if (File.Exists(apiApplicationFileInfo.FullName)) { - var asl = new AssemblyLoader(apiApplicationFileInfo.DirectoryName); - return asl.LoadFromAssemblyPath(apiApplicationFileInfo.FullName); + // Creating a new AssemblyContext instance for the same folder puts us at risk + // of loading the same DLL in multiple contexts, which leads to some unpredictable + // behavior in the loader. See https://github.com/dotnet/coreclr/issues/19632 + + return LoadFromAssemblyPath(apiApplicationFileInfo.FullName); } } return Assembly.Load(assemblyName);