Problem with Assemblies and loading type using reflection

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.
 
B

Bret Mulvey

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top