O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 Developer Command Prompt, run ildasm on the executable file and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required