I have a WPF assembly that i use in an interop scenario from native code using the LoadFrom loading context like this:
AppDomain.CreateInstanceFrom("c:\mydlls\mywpfstuff.dll", "myclass")
Note that mydlls is not the same folder as where the executable is located. This works fine for regular non-ui .NET dlls that i also load, but when I try to do this I get an error. I attached the AppDomain.CurrentDomain.AssemblyResolve event handler and a get a an event where it fails to load. The Name in the ResolveEventArgs is "mywpfstuff.resources" and the RequestingAssembly is empty. I have no file named "mywpfstuff.resources" and could not figure out how to do this assembly resolving myself.
The code line that triggers the error is the InitializeComponent(); call in my main user controls constructor.
It seems to me that the internal XAML (BAML?) mechanisms tries to load some resources, but uses that standard Load context instead of the LoadFrom context.
Is there any way around this problem, preferably by getting WPF to use the LoadFrom context or if that is not possible how to do the assembly resolving manually?