@@ -15,20 +15,6 @@ internal class PluginAssemblyLoader : AssemblyLoadContext
1515
1616 private readonly AssemblyName assemblyName ;
1717
18- private static readonly ConcurrentDictionary < string , byte > loadedAssembly ;
19-
20- static PluginAssemblyLoader ( )
21- {
22- var currentAssemblies = AppDomain . CurrentDomain . GetAssemblies ( ) ;
23- loadedAssembly = new ConcurrentDictionary < string , byte > (
24- currentAssemblies . Select ( x => new KeyValuePair < string , byte > ( x . FullName , default ) ) ) ;
25-
26- AppDomain . CurrentDomain . AssemblyLoad += ( sender , args ) =>
27- {
28- loadedAssembly [ args . LoadedAssembly . FullName ] = default ;
29- } ;
30- }
31-
3218 internal PluginAssemblyLoader ( string assemblyFilePath )
3319 {
3420 dependencyResolver = new AssemblyDependencyResolver ( assemblyFilePath ) ;
@@ -47,21 +33,15 @@ protected override Assembly Load(AssemblyName assemblyName)
4733 // When resolving dependencies, ignore assembly depenedencies that already exits with Flow.Launcher
4834 // Otherwise duplicate assembly will be loaded and some weird behavior will occur, such as WinRT.Runtime.dll
4935 // will fail due to loading multiple versions in process, each with their own static instance of registration state
50- if ( assemblyPath == null || ExistsInReferencedPackage ( assemblyName ) )
51- return null ;
36+ var existAssembly = Default . Assemblies . FirstOrDefault ( x => x . FullName == assemblyName . FullName ) ;
5237
53- return LoadFromAssemblyPath ( assemblyPath ) ;
38+ return existAssembly ?? ( assemblyPath == null ? null : LoadFromAssemblyPath ( assemblyPath ) ) ;
5439 }
5540
5641 internal Type FromAssemblyGetTypeOfInterface ( Assembly assembly , Type type )
5742 {
5843 var allTypes = assembly . ExportedTypes ;
5944 return allTypes . First ( o => o . IsClass && ! o . IsAbstract && o . GetInterfaces ( ) . Any ( t => t == type ) ) ;
6045 }
61-
62- internal bool ExistsInReferencedPackage ( AssemblyName assemblyName )
63- {
64- return loadedAssembly . ContainsKey ( assemblyName . FullName ) ;
65- }
6646 }
6747}
0 commit comments