Skip to content

Instantly share code, notes, and snippets.

@johnbabb
Created November 25, 2014 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbabb/f44f5f404ad421d5f72e to your computer and use it in GitHub Desktop.
Save johnbabb/f44f5f404ad421d5f72e to your computer and use it in GitHub Desktop.
CustomAssemblyResolver
public class CustomAssemblyResolver : DefaultAssembliesResolver
{
private Assembly[] plugins = (
from file in Directory.GetFiles(
AssemblyDirectory, "*.dll",
SearchOption.AllDirectories)
let assembly = Assembly.LoadFile(file)
select assembly)
.ToArray();
public static string AssemblyDirectory
{
get
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
public override ICollection<Assembly> GetAssemblies()
{
return base.GetAssemblies()
.Union(this.plugins).ToArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment