I want to Resolve a type without having a reference to the project where the type exist.
I want that the Resolve will load the correct assembly in runtime.
The issue is = that in runtime I decide which type to use… and according to that I want to load the correct assembly.
How can I do it?
thanks
What do you expect Unity to do? Vodoo?
You can either configure Unity using app/web.config and just drop the required assemblies in your app base folder. But that is configuration at design time.
Or you use code to configure the container which either lets you use
Assembly.Loadto get access to all assemblies that are not directly referenced by your app domain. Then you would have to use reflection of some kind to extract the types that will be dynamically registered.Or you can skip the “let’s be even more dynamic” approach and reference all neccessary assemblies in some kind of bootstrapper.
The third alternative would be to modularize your code configuration and use conventions to register those modules at runtime. Unity does not support this third approach out-of-the-box but there is a port of the StructureMap config engine available in the TecX project. See the documentation or the code in the TecX.Unity.Configuration project. Tests are available to demonstrate how it works.