2

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

starblue
  • 55,348
  • 14
  • 97
  • 151
  • I don't know why you need to load your assembly - but maybe ... have a look at a plugin framework like MEF (http://www.codeplex.com/MEF) – tanascius Jun 14 '09 at 20:36

3 Answers3

3

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
  • 6,507
  • 1
  • 38
  • 48
2

This may also help you: Problems loading assembly dependencies dynamically at run-time

Community
  • 1
  • 1
Juri
  • 32,424
  • 20
  • 102
  • 136
0

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

DOK
  • 32,337
  • 7
  • 60
  • 92