I'm having an assembly resolution problem with linked assemblies when writing a VSTO 4.0 add-in.
I have assemblies A, B, C and D; where Assembly A references B and B references C and D. During the build process I link assemblies C and D into assembly B. Then within assembly A we use two processes of redirecting assembly binding, both done in assembly A's static constructor.
- From assembly A, hook into the
AppDomain.CurrentDomain.AssemblyResolve += MyResolver
to redirect binding of C and D back into B (this dealt with 80% of use cases.) - Then to address the other 20% (or so I thought) from assembly A I call
Assembly.LoadFrom( <assembly B> )
Now I've come across an issue where a VSTO 4.0 application is getting the following exception when trying to initialize an object from assembly A.
Could not load file or assembly 'C, Version=#, Culture=neutral, PublicKeyToken=#' or one of its dependencies. The system cannot find the file specified.
When I look at the modules loaded into the AppDoamin I see assemblies A and B just as I do with an application that works properly; however, the Appdomain.CurrentDomain.AssemblyResolve
event never fires, or at least my private static Assembly MyResolver( Object sender, ResolveEventArgs args )
is never entered.
In my search the answer I found that seemed to be most in-line with my problem was here...
http://widequestion.com/question/vsto-assemblyresolve-issue/
All that being said his answer of, "There is no other way" seems... well, wrong but I can't disprove that. Is anyone aware of how I might be able to control assembly redirection in this context?