Reputation: 3485
String commClass = "ClassA";
Assembly objAssembly = Assembly.Load("DemoClassLibrary");
IA iFace = (IA)objAssembly.CreateInstance(commClass);
iFace.run();
I am getting null in iFace variable
public interface IA
{
void run();
}
public class ClassA : IA
{
string str = string.Empty;
public void run()
{
Console.WriteLine("{0}", DateTime.Now.Ticks);
Logger.Logger.CreateLog(DateTime.Now.Ticks.ToString());
}
}
above is the class declaration by the namespace DemoClassLibrary
can u please help me out..
thnx
Upvotes: 0
Views: 88
Reputation: 1500595
This could well be the problem:
above is the class declaration by the namespace DemoClassLibrary
You need to pass a fully-qualified name to Assembly.CreateInstance
, so you may want:
String commClass = "DemoClassLibrary.ClassA";
Upvotes: 4