c# - Class instantiated from DLL does not seem to be implementing interface properly -
i have class attempting instantiate through use of assembly , activator, class implements interface, when run instance of class through conditional checks class implements it, getting false. problem?
my code checking implementation:
string classname = myclass; type type = null; assembly assembly = assembly.loadfile("@c:\\mydll", new evidence(appdomain.currentdomain.evidence)); type = assembly.gettype(classname); object instance = activator.createinstance(type); //never makes past conditional if (!(instance myinterface) { //it endsup in here, when shouldn't. system.writeline("error"); } else{ //this needs happen } code class myclass outside scope of of this, , in mydll
public class myclass: myinterface { //contents irrelevent problem } i @ loss why not passing conditional. instantiation class wrong? note huge rookie when comes using assembly/activator , using interfaces.
most reason - both dll , code have own version of myinterface. happen either because
- one did not want spend time come unique name interface,
- someone decided share interface source instead of via assembly reference,
- good named interfaces in different namespaces ,
usingwrong one.
Comments
Post a Comment