B
Big Daddy
I have an interface called PeriodicJob. In a DLL, I declare the
interface and then create a class that implements the interface. In a
different executable, I also declare the interface. I then load the
assembly with late binding and create an instance of the class with
reflection. I try to cast the object to the class type of the
interfact, but I get an invalid cast exception. It says that the
object I am creating isn't a PeriodicJob. But the class does
implement the PeriodicJob interface. I am guessing the reason it
doesn't work is because when I declare the interface in the DLL and
then declare it again in the EXE, even though they have the same name
and structure, they are considered to be two different interfaces.
Here's the code where I use reflection:
Assembly a = Assembly.LoadFrom(path + "\\" +
assemblyName);
Object obj = a.CreateInstance(className);
PeriodicJob pj = (PeriodicJob)obj;
How do I make it such that both the DLL and the EXE use the same
actual interface? Do I have to declare the interface in a totally
different DLL and then reference that DLL from both my EXE and DLL
that has the implementation?
thanks in advance,
John
interface and then create a class that implements the interface. In a
different executable, I also declare the interface. I then load the
assembly with late binding and create an instance of the class with
reflection. I try to cast the object to the class type of the
interfact, but I get an invalid cast exception. It says that the
object I am creating isn't a PeriodicJob. But the class does
implement the PeriodicJob interface. I am guessing the reason it
doesn't work is because when I declare the interface in the DLL and
then declare it again in the EXE, even though they have the same name
and structure, they are considered to be two different interfaces.
Here's the code where I use reflection:
Assembly a = Assembly.LoadFrom(path + "\\" +
assemblyName);
Object obj = a.CreateInstance(className);
PeriodicJob pj = (PeriodicJob)obj;
How do I make it such that both the DLL and the EXE use the same
actual interface? Do I have to declare the interface in a totally
different DLL and then reference that DLL from both my EXE and DLL
that has the implementation?
thanks in advance,
John