如何在运行时确定.Net程序的入口点?

Ale*_*xey 5 c# reflection

假设我的程序中有两种类型,Foo并且Bar.两者都有static void Main(string[] args).要编译此程序,需要编译器标志/main:class.

是否有可能在运行时确定哪两种类型包含入口点,即获取TypeInfoMethodInfo指向正确的类或正确的Main方法?

UPD:更确切地说,是否可以从链接到主应用程序的类库(即,没有可能的选项的先验知识)这样做?

Hen*_*man 9

一个组件有一个 public virtual MethodInfo EntryPoint { get; }