MEF plugin cannot find library link

I am implementing a plug-in system with MEF, and so far it is working fine. I recently ran into a problem: the main application uses the SQLite database, and now I have a plugin that also needs to access this database. When I copy a plugin to my plugin directory, mef picks it correctly, but as soon as it tries to access something using SQlite, I get a System.IO exception saying that it cannot find the sqlite SQL file from which it depends.

I also tried copying sqlite dlls to the plugin directory, but it still won't work. Should any libraries that I referenced in my main application also be available in my plugin? And even if not, should the plugin not find libraries if they are in the same directory?

Any help would be appreciated.

+4
source share
1 answer

The SQLite assembly should be in your path or in your application directory, and not in your modules directory. If that is the case, and you still get the same error, then this seems like the same problem I posted here with the following solution:

public static class AssemblyResolverFix { //Looks up the assembly in the set of currently loaded assemblies, //and returns it if the name matches. Else returns null. public static Assembly HandleAssemblyResolve( object sender, ResolveEventArgs args ) { foreach( var ass in AppDomain.CurrentDomain.GetAssemblies() ) if( ass.FullName == args.Name ) return ass; return null; } } //in main AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolverFix.HandleAssemblyResolve; 
+2
source

All Articles