How to Activator.CreateInstance a Type from within an other assembly?

  • Thread starter Thread starter Matthias Straka
  • Start date Start date
M

Matthias Straka

Hi!

I have a project with a Dll and a exe. My dll has a set of functions that
can activate some classes (these classes have all the same interface defined
in the dll). That works fine with classes that are defined inside the Dll,
but when I want to activate a class defined in my exe (which references the
dll) the Type cannot get loaded. Is there any way to
Type.GetType("classname.of.class.in.exe")-Create a Type in a function of the
Dll?

matthias
 
Matthias Straka said:
I have a project with a Dll and a exe. My dll has a set of functions that
can activate some classes (these classes have all the same interface defined
in the dll). That works fine with classes that are defined inside the Dll,
but when I want to activate a class defined in my exe (which references the
dll) the Type cannot get loaded. Is there any way to
Type.GetType("classname.of.class.in.exe")-Create a Type in a function of the
Dll?

You need to either get the assembly (either by finding it in the
already-loaded assemblies in the AppDomain, or loading it with
Assembly.Load) and call Assembly.GetType, or use GetType with the fully
qualified name of the type, including assembly information.
 
Back
Top