Friday, 15 April 2011

c# - Is it possible to call Activator.CreateInstance on a type in an assembly that is not statically referenced? -



c# - Is it possible to call Activator.CreateInstance on a type in an assembly that is not statically referenced? -

is possible user activator.createinstance() instantiate type given type.fullname , assembly name though assembly not referenced executing assembly?

yes, first have load assembly.

suppose have "plugins" folder into:

foreach (fileinfo f in new directoryinfo("c:\\plugins").getfiles("*.dll")) { system.reflection.assembly.loadfrom(f.fullname); }

now assemblies loaded , can create type using activator.createinstance.

c# .net dependency-injection instantiation activator

No comments:

Post a Comment