开发者

What exactly happens when you run a .NET executable (step by step to the point where the program is loaded and running)?

开发者 https://www.devze.com 2023-02-12 00:32 出处:网络
When you run a .NET executable, what exactly takes place, step by step in order. My basic understanding is that you run the executable, the CLR does some checking, compiles the CIL it into platform sp

When you run a .NET executable, what exactly takes place, step by step in order. My basic understanding is that you run the executable, the CLR does some checking, compiles the CIL it into platform specific code, loads it up along with the specified required dll's (as specified in the manifest(s)) and runs your program.

Can someone elaborate on this, down to the "it allocates memory for this and that" level? I would really like to k开发者_运维百科now what is happening from when you double-click on the executable to when your program is successfully running.

P.S. diagrams, external links welcome. :-)


There's a reason that this information isn't easily accessible - because Microsoft have learnt that as soon as you publish anything it suddenly has to remain fixed for all time (source: 90% of Raymond Chen's blog).

The ECMA standard is available from here, though it appears from the table of contents that it may not cover the material you are after. It certainly specifies the structure, though probably not internal implementation details.

For specific internal details, you need to provide at least the exact version of the .NET Framework you are interested in (and we'll ignore other CLRs such as Mono) and the details of the program you are running.

If you have a practical (ie. debugging) reason for needing these details, start your executable with windbg and step through the loading process. (This will also work for interests sake, though it may not be as enjoyable.)

Finally, Mono is open source, so you can browse their code to see how they chose to implement it. There is obviously no guarantee that it is identical to the way Microsoft implemented theirs, but as an academic exercise either should be sufficient.


One book to rule them all: CLR via C#.

0

精彩评论

暂无评论...
验证码 换一张
取 消