tags:

views:

133

answers:

4

hi ,

I load my assembly at runtime (but this assemby is not refenced by the project)

Assembly a = Assembly.LoadFile(@"fulpath\assName.dll");

after that I want to use one class from this dll by reflection

obj = Activator.CreateInstance(Type.GetType("assemblyqualifiedname"));
mi = obj.GetType().GetMethod("methodname");
mi.Invoke(obj, null);

unfortunately , bull returns from Type.GetType("assemblyqualifiedname");

I dont understand , why I must to add reference od dll to project ?

Load assembly should be enough , but it doesnt .

thanks ...

+3  A: 

When you load an assembly manually, you should use its getType method. Type.getType will use the calling assembly and its reference to search for the type. a.GetType will find the type, because it looks inside the loaded assembly.

mihi
A: 

What is your objection to adding a reference to the DLL in the project?

DOK
A: 

thanks , it works :)

can you please set the accepting answer. thx :)
Juri