How to load assembly into memory and execute it

前端 未结 3 882
暗喜
暗喜 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:30

    if you check any WinForm application Program.cs file you'll see there always these 2 lines

    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    

    you need to call as well them in your assembly. At least this is what your exception says.

提交回复
热议问题