I'm implementing a module with Views created in a separate project and hence a separate assembly. I'm using UnityContainer and DirectoryLookUp for module discovery and placing both the module and view binaries inside modules folder.
All works fine, container is able to resolve and create the view.
I also have a requirement to generate the view type dynamically and load it. For that I'm using Type.GetType("<fully qualified name of type, fully qualified name of assembly>", true). For some strange reason this doesn't
work and an exception is thrown at the run time. If view is created in the same assembly in which module resides then Type.GetType works fine.
After debugging, I realised that Module assembly is loaded by calling Assembly.LoadFrom() method inside AssemblyResolve event of AppDomain, however, the view assembly is loaded via. container while resolving the view type. Both the binaries are loaded
in AppDomain and AppDomain.CurrentDomain.GetAssemblies(..) returns both of these.
Also, if I explicitely pick up the view assembly from loaded assemblies and then call GetType method on assembly it works fine - the workaround being used currently.
My guess is that it is related to the way container resolves the types. May be container loads the assembly in less privilege or different context. Can somebody please explain what's going "under the hood" and what should be the best way to handle