I\'m contemplating adding some extensibility into an existing app by providing a few predefined interfaces that can be implemented by \"plugins\" dropped at a specific locat
Whatever your reasons may be to avoid your 3 points (which I think are more reliable and apt), you can take advantage of Assembly Resolve Event.
Include code such as following in your core.dll
static Assembly AppDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
//replace the if check with more reliable check such as matching the public key as well
if (args.Name.Contains(Assembly.GetExecutingAssembly().GetName().Name))
{
Console.WriteLine("Resolved " + args.Name + " as " + Assembly.GetExecutingAssembly().GetName());
return Assembly.GetExecutingAssembly();
}
return null;
}
Bind the above handler before attempting to load your plugins. If you load the plugins in current Appdomain then bind it to AssemblyResolve
of current domain.
For e.g.
[SecurityPermission(SecurityAction.Demand, ControlAppDomain = true)]
public static void LoadPlugins()
{
AppDomain.CurrentDomain.AssemblyResolve += AppDomain_AssemblyResolve;
Assembly pluginAssembly = AppDomain.CurrentDomain.Load("MyPlugin");
}