this im doing:
byte[] bytes = file.readallbytes(@application.startuppath+"/updatemainprogaramapp.exe"); assembly assembly = assembly.load(bytes); // load assemly //assembly assembly = assembly.loadfrom(assemblyname); // walk through each type in assembly looking our class methodinfo method = assembly.entrypoint; if (method != null) { // create istance of startup form main method object o = assembly.createinstance(method.name); // invoke application starting point try { method.invoke(o, null); } catch (targetinvocationexception e) { console.writeline(e.tostring()); } }
the problem throws targetinvocationexception
- finds method main, throws exception since on line:
object o = assembly.createinstance(method.name);
o
remaining null. dug bit stacktrace , actual error this:
innerexception = {"setcompatibletextrenderingdefault should called before creating firstfirst iwin32window object in program"} (this translation since gives me stacktrace in half hebrew half english since windows in hebrew.)
what doing wrong?
the entry point method static, should invoked using null value "instance" parameter. try replacing after assembly.load line following:
assembly.entrypoint.invoke(null, new object[0]);
if entry point method not public, should use invoke overload allows specify bindingflags
.
Comments
Post a Comment