@@ -15,20 +15,6 @@ internal class PluginAssemblyLoader : AssemblyLoadContext
15
15
16
16
private readonly AssemblyName assemblyName ;
17
17
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
-
32
18
internal PluginAssemblyLoader ( string assemblyFilePath )
33
19
{
34
20
dependencyResolver = new AssemblyDependencyResolver ( assemblyFilePath ) ;
@@ -47,21 +33,15 @@ protected override Assembly Load(AssemblyName assemblyName)
47
33
// When resolving dependencies, ignore assembly depenedencies that already exits with Flow.Launcher
48
34
// Otherwise duplicate assembly will be loaded and some weird behavior will occur, such as WinRT.Runtime.dll
49
35
// 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 ) ;
52
37
53
- return LoadFromAssemblyPath ( assemblyPath ) ;
38
+ return existAssembly ?? ( assemblyPath == null ? null : LoadFromAssemblyPath ( assemblyPath ) ) ;
54
39
}
55
40
56
41
internal Type FromAssemblyGetTypeOfInterface ( Assembly assembly , Type type )
57
42
{
58
43
var allTypes = assembly . ExportedTypes ;
59
44
return allTypes . First ( o => o . IsClass && ! o . IsAbstract && o . GetInterfaces ( ) . Any ( t => t == type ) ) ;
60
45
}
61
-
62
- internal bool ExistsInReferencedPackage ( AssemblyName assemblyName )
63
- {
64
- return loadedAssembly . ContainsKey ( assemblyName . FullName ) ;
65
- }
66
46
}
67
47
}
0 commit comments