I'm trying to 'convert' a plug-in system of sorts to use the unity container.
The problem I'm having is that I can't register the types from assemblies that were not yet loaded. Since it is a plugin system after all, this makes a lot of sense. I don't want to load the assembly myself at all, but I'd like to register a interface with
several types from this plug-in assembly.
I first tried to register the type by using the Type.GetType method passing the fully qualified type name, but it also seems to need the assembly to be pre loaded first.
I then thought about configuring the container through XML, but I get this message:
The type name or alias <type> could not be resolved. Please check your configuration file and verify this type name.
In this case, if I go to the code and add this right before calling LoadConfiguration():
var x = typeof(<type_from_plugin_assembly>);
It works, because the assembly is then loaded to the current domain.
Why does this happen? Is it intended that only loaded assemblies can have registrations? If so, how can I circumvent this in my case? I can't just call something random from the assemblies, since they could be ANY assembly, not just our companies ones.
What we currently have is a NameValueCollection (in a config file) containing a fully qualified type string and a number that will be later used to retrieve the instance. Ideally, it would be just a matter of iterating this config file and registering the types
with the plugin interface, using the number as the registration name. I thought this would work, but it does not for the above reasons.
I saw this question in SO, but since it's quite old I decided to ask here too:
Thanks in advance as always,