From a72b849bc789ba7108a6e511fe00b0ece87d8a24 Mon Sep 17 00:00:00 2001 From: David Shiflet Date: Tue, 25 Sep 2018 16:02:00 -0400 Subject: [PATCH] Change ExtensionServiceProvider to use a single AssemblyLoadContext (#696) * Switch to the unified SMO NuGet so all binaries are strong named and signed. * use one AssemblyLoader instance for all loads * Revert "use one AssemblyLoader instance for all loads" This reverts commit 48c59ffd5c57152de281c87acdbcad7ddf7ab760. * Stop creating multiple AssemblyLoadContext objects during composition, per https://github.com/dotnet/coreclr/issues/19632 * restore high entropyva property * Improve the comment --- .../Extensibility/ExtensionServiceProvider.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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);