i'm using third party dll. i'm using class in namespace namespace.class
.
in newer versions class has been moved namespace newnamespace.newpart.class
. code needs support both cases. how solve this?
develop late binding of 3rd party dll , check version is. can create new instance of right object in right namespace.
here example code:
//load dll system.reflection.assembly mydllassembly = system.reflection.assembly.loadfile("myspeciallibrary.dll"); //create object object mydllobjectinstance; //initialize object if (mydllassembly.imageruntimeversion == "version2") { mydllobjectinstance = (object)mydllassembly.createinstance("mydllnamespace.mydllobject"); } else { mydllobjectinstance = (object)mydllassembly.createinstance("mydllnamespace.newnamespace.mydllobject"); }
Comments
Post a Comment