0

I have the following qualified class name stored in a string:

string className="Project.LogicLayer.FunctionsLayer.Medic";

Now I need a new instance of the class from using that string.

I tried this but it always returns null:

Type t=Type.GetType(className);
object = Activator.CreateInstance(t);
ventiseis
  • 3,029
  • 11
  • 32
  • 49
MagnunStalin
  • 94
  • 1
  • 9

1 Answers1

4

Try this overload of Activator.CreateInstance

Activator.CreateInstance("MedicAssembly", "Project.LogicLayer.FunctionsLayer.Medic");
Colin Grealy
  • 615
  • 4
  • 12
  • Thanks, now it works, I have based in your example. `Assembly asm = Assembly.LoadFrom("C:\\Projec\\AppMedical\\packages\\BussinessLayer\\lib\\net451\\Buessinesslayer.dll"); Type t = asm.GetType(Project.LogicLayer.FunctionsLayer.Medic); var obj = Activator.CreateInstance(t);` – MagnunStalin Mar 30 '16 at 22:40