This post is somehow related to the
one
I made just a couple of days ago. The application plugins (dlls placed in a special folder of my app) are loaded
dynamically at run-time with my small "plugin framework" I'm developing. Now the problem I faced is that these plugins
may need additional 3rd-party dlls which are however then not found by the main application.
My first approach was
to attach a handler that is called when there are exceptions in loading a certain assembly. The idea would then have
been to modify the path of the assembly such that it points to a folder "dependencies" on my application where all the
needed 3rd-party dlls are deployed.
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
//find the path to the assembly and then load and return it by
//return Assembly.Load("pathToDependencies/failedAssembly.dll");
}
This
seemed to work initially but sadly I got exceptions from the "Presentation.Zune.dll" which I was then not able to
handle properly. So thanks to the guys at
StackOverflow.com
this is the final working solution. Put the following code in your App.config:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="dependencies"/>
</assemblyBinding>
</runtime>
</configuration>
"dependencies"
is the folder on the application directory where the 3rd-party dlls can be found.
Questions? Thoughts? Hit me up
on Twitter