Skip to content

Commit

Permalink
AssemblyResolve (neo-project#1349)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang authored and Luchuan committed Jan 10, 2020
1 parent a3c4a94 commit f0c454a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/neo/Plugins/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,23 @@ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEven
if (args.Name.Contains(".resources"))
return null;

AssemblyName an = new AssemblyName(args.Name);

Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName == args.Name);
if (assembly != null)
return assembly;
if (assembly is null)
assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name == an.Name);
if (assembly != null) return assembly;

AssemblyName an = new AssemblyName(args.Name);
string filename = an.Name + ".dll";
string path = filename;
if (!File.Exists(path)) path = Combine(GetDirectoryName(Assembly.GetEntryAssembly().Location), filename);
if (!File.Exists(path)) path = Combine(PluginsDirectory, filename);
if (!File.Exists(path)) path = Combine(PluginsDirectory, args.RequestingAssembly.GetName().Name, filename);
if (!File.Exists(path)) return null;

try
{
return Assembly.Load(File.ReadAllBytes(filename));
return Assembly.Load(File.ReadAllBytes(path));
}
catch (Exception ex)
{
Expand Down

0 comments on commit f0c454a

Please sign in to comment.