Quoted from this site (click):
Main is declared inside a class or struct. Main must be static and it should not be public.
It means that the Main method can be public.
Now consider the following 2 projects:
Project 1: HelloWorld
using static System.Console;
namespace HelloWorld
{
class Program
{
public static void Main()
{
WriteLine("Hello World");
}
}
}
I assign public
modifier to the Main.
Then I compile it to produce an application named HelloWorld.exe
.
Project 2: Invoker
namespace Invoker
{
class Program
{
static void Main()
{
// I want to invoke Main in HelloWorld.exe here.
// How to do it?
}
}
}
This project tries to invoke Main
defined in HelloWorld.exe
Question
Without using Process
, how can the Invoker.exe
call public Main
defined in HelloWorld.exe
? This question is used to find an example to invoke public Main from outside. That is why I don't want to use Process
.