How to load assembly into memory and execute it

前端 未结 3 905
暗喜
暗喜 2021-01-01 00:52

This is what im doing:

byte[] bytes = File.ReadAllBytes(@Application.StartupPath+\"/UpdateMainProgaramApp.exe\");
Assembly assembly = Assembly.Load(bytes);
/         


        
3条回答
  •  孤独总比滥情好
    2021-01-01 01:51

    The entry point method is static, so it should be invoked using a null value for the "instance" parameter. Try replacing everything after your Assembly.Load line with the following:

    assembly.EntryPoint.Invoke(null, new object[0]);
    

    If the entry point method is not public, you should use the Invoke overload that allows you to specify BindingFlags.

提交回复
热议问题