Under the Hood
How does the CLR know what type contains the entry point and how it’s called? Even though we didn’t explicitly state this, the containing type’s name doesn’t matter. In line with Visual Studio’s choice, we used Program, but that’s not mandatory. So the idea of the CLR having hard-coded knowledge about looking for a method called Main on a type called Program falls apart.
It turns out the CLR doesn’t care about the name of the method or its containing type at all; instead, the answer lies in metadata used to keep track of the entry-point method within the defining assembly. You can see this using ildasm.exe when looking at the code for the entry-point method. From a Visual Studio 2010 command prompt, run ildasm on the executable ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access