Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plugin to have dependencies #1348

Closed
wants to merge 1 commit into from

Conversation

@shargon shargon requested a review from erikzhang December 10, 2019 11:35
@erikzhang
Copy link
Member

You don't need to load the dependencies. It will load them automatically if you put them in the right place.

@erikzhang
Copy link
Member

AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name.Contains(".resources"))
return null;
Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName == args.Name);
if (assembly != null)
return assembly;
AssemblyName an = new AssemblyName(args.Name);
string filename = an.Name + ".dll";
try
{
return Assembly.Load(File.ReadAllBytes(filename));
}
catch (Exception ex)
{
Utility.Log(nameof(Plugin), LogLevel.Error, $"Failed to resolve assembly or its dependency: {ex.Message}");
return null;
}
}

@shargon
Copy link
Member Author

shargon commented Dec 10, 2019

But then we need to to copy the dependencies outside the Plugin folder

@erikzhang
Copy link
Member

@shargon Please review #1349

@shargon shargon closed this Dec 10, 2019
@shargon shargon deleted the plugin-dependencies branch December 10, 2019 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants