S
Simon X-Session
Hi !
I hope somebody can help me, i'm completly out of mind.
My problem:
I have a class inherited from Windows.Forms.Control named BasicModule,
which implements an interface named IModule (this has nothing to do
with the Module-Class of the framework. it's selfmade).
Now when I instantiate an object dynamically from an assembly created
from the source of BasicModule, i'm able to cast this object to
Control, but not to IModule, not even to BasicModule.
so that you can imagine something:
public class BasicModule : Control, IModule
{ ... }
public interface IModule
{ ... }
now the critical part:
ModuleEntity selected = (ModuleEntity)trvQueries.SelectedNode.Tag;
object instance = selected.Library.CreateInstance("DAP." +
selected.Description.Class,true);
pnlModule.Controls.Add((Control)instance);
((IModule)instance).DBConnection = dbConnection;
ModuleEntity holds information about the loaded assembly (stored in
member "Library", "DAP" is namespace of project)
pnlModule is a panel to which i want to add the control
it just doesn't work !
the debugger even tells me, that "instance" is of type BasicModule,
but i'm not able to cast it to this class
i also tried to make a abstract base-class, which inherits Controls
and implements IModule
and inherit BasicModule from this base-class
but i also can't cast to that abstract base-class !
i'm freaking out
please help me, i'm in serious trouble if i don't solve the problem
soon
ps: it's an requirement, that i can load any assembly-class, which
implements the IModule interface, at runtime
this is the base of an extensible application which loads specific
dlls described in some xml-configuration-file
so you don't have to rebuild the application when adding new modules
I hope somebody can help me, i'm completly out of mind.
My problem:
I have a class inherited from Windows.Forms.Control named BasicModule,
which implements an interface named IModule (this has nothing to do
with the Module-Class of the framework. it's selfmade).
Now when I instantiate an object dynamically from an assembly created
from the source of BasicModule, i'm able to cast this object to
Control, but not to IModule, not even to BasicModule.
so that you can imagine something:
public class BasicModule : Control, IModule
{ ... }
public interface IModule
{ ... }
now the critical part:
ModuleEntity selected = (ModuleEntity)trvQueries.SelectedNode.Tag;
object instance = selected.Library.CreateInstance("DAP." +
selected.Description.Class,true);
pnlModule.Controls.Add((Control)instance);
((IModule)instance).DBConnection = dbConnection;
ModuleEntity holds information about the loaded assembly (stored in
member "Library", "DAP" is namespace of project)
pnlModule is a panel to which i want to add the control
it just doesn't work !
the debugger even tells me, that "instance" is of type BasicModule,
but i'm not able to cast it to this class
i also tried to make a abstract base-class, which inherits Controls
and implements IModule
and inherit BasicModule from this base-class
but i also can't cast to that abstract base-class !
i'm freaking out
please help me, i'm in serious trouble if i don't solve the problem
soon
ps: it's an requirement, that i can load any assembly-class, which
implements the IModule interface, at runtime
this is the base of an extensible application which loads specific
dlls described in some xml-configuration-file
so you don't have to rebuild the application when adding new modules