G
Guest
I am having problems with casting or converting a class to to an interface
from which it derives. I'm certain that it's due to how it's being loaded,
but I'm not sure how to get past the problem.
Here's a general outline of the architecture. It's oversimplified, but I
think it's enough info to help:
Assembly A.dll
{
interface IMyBase {}
}
Assembly B.dll (references A.dll)
{
class PlugIn : IMyBase {}
}
Assembly C.exe (references A.dll)
{
class InternalClass : IMyBase {}
class MyUI
{
// use IMyBase stuff here
}
}
Now if C.exe loads up an instance of InternalClass, it can cast it to
IMyBase and use it no problem.
If it loads B.dll and creates an instance of PlugIn through reflection I
*cannot* then cast it to an IMyBase.
How can I get access to the dynamically loaded plug in instance's members as
the base interface type? Til now I've been hacking it and just doing things
like getting functions by name, not by using the interface contract, but now
I need to create a handler for an event in the plug in and my hacks are
getting really ugly.
-Chris
from which it derives. I'm certain that it's due to how it's being loaded,
but I'm not sure how to get past the problem.
Here's a general outline of the architecture. It's oversimplified, but I
think it's enough info to help:
Assembly A.dll
{
interface IMyBase {}
}
Assembly B.dll (references A.dll)
{
class PlugIn : IMyBase {}
}
Assembly C.exe (references A.dll)
{
class InternalClass : IMyBase {}
class MyUI
{
// use IMyBase stuff here
}
}
Now if C.exe loads up an instance of InternalClass, it can cast it to
IMyBase and use it no problem.
If it loads B.dll and creates an instance of PlugIn through reflection I
*cannot* then cast it to an IMyBase.
How can I get access to the dynamically loaded plug in instance's members as
the base interface type? Til now I've been hacking it and just doing things
like getting functions by name, not by using the interface contract, but now
I need to create a handler for an event in the plug in and my hacks are
getting really ugly.
-Chris