G
Guest
I have a C++/CLI interface IPlugin in one assembly (a windows service) that
is inherited and implemented in another assembly (dll) by a class CPlugin. I
want to be able to create instance of this class dynamically at runtime, so I
load the dll assembly using
Assembly^ assembly = Assembly::LoadFrom(directory + assemblyName + ".dll");
then create an instance of CPlugin using
Object^ obj = (assembly->CreateInstance(assemblyName+".C"+assemblyName));
Where assemblyName is PlugIn. This creates an instance of an object quite
happily. But when I try to do the following it throws an InvalidCastException
IPlugin^ iPI = safe_cast<IPlugin^>(obj);
I have also tried dynamic_cast which returns a undefined object.
So the question is why can't I cast CPlugin to IPlugin when it inherits it
publically?
Thanks
Colin
is inherited and implemented in another assembly (dll) by a class CPlugin. I
want to be able to create instance of this class dynamically at runtime, so I
load the dll assembly using
Assembly^ assembly = Assembly::LoadFrom(directory + assemblyName + ".dll");
then create an instance of CPlugin using
Object^ obj = (assembly->CreateInstance(assemblyName+".C"+assemblyName));
Where assemblyName is PlugIn. This creates an instance of an object quite
happily. But when I try to do the following it throws an InvalidCastException
IPlugin^ iPI = safe_cast<IPlugin^>(obj);
I have also tried dynamic_cast which returns a undefined object.
So the question is why can't I cast CPlugin to IPlugin when it inherits it
publically?
Thanks
Colin