lundi 22 février 2016

Create an instance of a class in a different assembly by strings

I need to create an instance of a class, while only having the full class name (with namespaces) and the file-name of the assembly where the class is defined. I know that the assembly is in the current working directory. The default constructor (with no arguments) should be used, as it is the only one available.

After some google, stack overflow and MSDN I am still not sure what the best solution is. Multiple assemblies will be loaded, so using an application domain would be good (?).

The application domain documentation says, I should use CreateInstanceAndUnwrap, but there I need the full assembly name. And as far as I know, I only can get it by loading the assembly. This seems somewhat very inefficient.

Which is a good way to create an instance of a class in a currently unloaded assembly?

Thanks!





Aucun commentaire:

Enregistrer un commentaire