How to load several assembly in c # and invoke them

3

How can I load several assembly and use them? Since when I charge one by means of:

var assemblyBytes = File.ReadAllBytes("ReflectionAssemblyLoadTarget.exe");
var loadMethod = typeof(Assembly).GetMethod("Load", new Type[] { typeof(byte[]) });
var newAssembly = loadMethod.Invoke(null, new object[] { assemblyBytes });

((Assembly)newAssembly).EntryPoint.Invoke(null, new object[] { args });

I charge and call but when I charge several for example:

//Load the bytes as an assembly
Assembly exeAssembly = Assembly.Load(bytes1);

//Execute the assembly
object[] parameters = new object[1];                //Don't know 
 exeAssembly.EntryPoint.Invoke(null, parameters);

//Load the bytes as an assembly
Assembly exeAssembl = Assembly.Load(bytes2);

//Execute the assembly
object[] parameter = new object[1];                //Don't know 
 exeAssembl.EntryPoint.Invoke(null, parameter);

Only the first one invokes me but the others do not. Why? What is this about? Can only one assembly be used per program is that why?

    
asked by Sergio Ramos 04.06.2017 в 00:41
source

1 answer

1

Since your assemblies that you refer are executable, is the option to execute them via Process.Start?

using System.Diagnostics;
...
Process.Start("ruta/ensamblado");
    
answered by 08.06.2017 в 20:58