How can I start my assembly in c #

0

Hello, I previously asked about an error that I returned when loading my assembly. But now my question is once loaded as I start it? The code of the function is.

internal static Assembly AssemblyHome(byte[] data)
        {

What I do is:

var a = AssemblyHome(data);
a.EntryPoint.Invoke(null,null);

My program has an entrypoint and everything, but once I write it down, how can I invoke it?

    
asked by sir mirror 02.01.2018 в 12:01
source

1 answer

4

Assuming that the EntryPoint corresponds to a standard Main method (I do not know if it is possible that it is not), then you must pass to Invoke the parameter that corresponds to the parameter args of Main :

static void Main(string[] args)
{
    // ...
}

So depending on what value you want to spend for the args , you can choose among all the following variations:

a.EntryPoint.Invoke(null,new object[] {null}); // args == null
a.EntryPoint.Invoke(null,new object[] {new string[0]}); // args == {}
a.EntryPoint.Invoke(null,new object[] {new string[] {"p1"}}); // args == {"p1"}
a.EntryPoint.Invoke(null,new object[] {new string[] {"p1", "p2"}}); // args == {"p1", "p2"}
// etc.
    
answered by 02.01.2018 в 14:28