lundi 2 octobre 2017

How to determine a .Net program's entry point at runtime?

Let's say I have two types in my program, Foo and Bar. Both have a static void Main(string[] args). To compile this program, a compiler flag /main:class is needed.

Is it possible to determine at runtime which of the two types contains the entry point, i.e., to get a TypeInfo or MethodInfo pointing me to the correct class or the correct Main method?

UPD: to be more precise, is it possible to do so from a class library linked to the main application (i.e., without prior knowledge of possible options)?





Aucun commentaire:

Enregistrer un commentaire