Problem with Assemblies and loading type using reflection

  • Thread starter Thread starter Sacha
  • Start date Start date
S

Sacha

If I use Assembly.LoadFile("name.dll") and then I want to create instace of
class inside the assembly using reflection Type.GetType("class.name")
doesn't work unless I do

Assembly asm = Assembly.LoadFile("name.dll");
Type t = asm.GetType("class.name");

Is there a way to expose the new Assembly globally dynamically so I can use
the standard Type.GetType()? I don't want to keep track of which assembly I
loaded and where each class is store. In my code, I only know at runtime how
many new assemblies I have to load


Tks.
 
Sacha said:
If I use Assembly.LoadFile("name.dll") and then I want to create instace of
class inside the assembly using reflection Type.GetType("class.name")
doesn't work unless I do

Assembly asm = Assembly.LoadFile("name.dll");
Type t = asm.GetType("class.name");

Is there a way to expose the new Assembly globally dynamically so I can use
the standard Type.GetType()? I don't want to keep track of which assembly I
loaded and where each class is store. In my code, I only know at runtime how
many new assemblies I have to load

Type.GetType allows you to specify the assembly name, which you can
incorporate at runtime. See the documentation for Type.GetType(string) on
MSDN. Without specifying the assembly name, Type.GetType only looks in the
calling assembly and in mscorlib.
 
Back
Top