How does the CLR identify the main method of an application in order to begin the execution?
What exactly is the sequence of operations the CLR takes when you execute a开发者_JAVA百科 .exe file?It's a C# standard that the entry point is called Main
. When compiled to IL it is marked as .entrypoint
which is what the CLR uses to identify the method to start.
(Source: Why is Main method private?)
A .NET executable file is also an ordinary Win32 executable. At the normal Win32 entrypoint a small bootstrap code is placed which starts the CLR. On a pre-WinXP OS, the executable is started as a normal Win32 exe, invoking the boostrap code that starts the CLR. Once started, the CLR looks up the .entrypoint in the IL code and starts execution there. On WinXP and above the OS recognizes the file as a CLR executable and directly invokes the CLR.
(Source: http://www.dotnetperformance.com/downloads/ngen.doc)
精彩评论