当您运行 .NET 可执行文件时到底会发生什么(逐步加载并运行程序)?

发布于 2024-10-18 03:25:00 字数 214 浏览 5 评论 0原文

当您运行 .NET 可执行文件时,按顺序一步一步到底发生了什么。我的基本理解是,您运行可执行文件,CLR 会进行一些检查,将 CIL 编译为特定于平台的代码,将其与指定的所需 dll(如清单中指定的)一起加载并运行您的程序。

有人可以详细说明这一点,直到“它为这个和那个分配内存”级别吗?我真的很想知道从双击可执行文件到程序成功运行期间发生了什么。

PS图,欢迎外部链接。 :-)

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 know what is happening from when you double-click on the executable to when your program is successfully running.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏天碎花小短裙 2024-10-25 03:25:00

一本书即可统治​​所有这些:CLR via C#

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

一梦等七年七年为一梦 2024-10-25 03:25:00

这些信息不易获取是有原因的 - 因为 Microsoft 已经了解到,一旦您发布任何内容,它就会突然必须始终保持固定状态(来源:Raymond Chen 的博客)。

ECMA 标准可从此处获取,尽管它出现在目录可能不包含您想要的材料。它当然指定了结构,尽管可能不是内部实现细节。

对于特定的内部详细信息,您需要至少提供您感兴趣的 .NET Framework 的确切版本(我们将忽略其他 CLR,例如 Mono)以及您正在运行的程序的详细信息。

如果您有实际(即调试)原因需要这些详细信息,请使用 windbg 并逐步完成加载过程。 (这也可以出于兴趣考虑,尽管可能不那么令人愉快。)

最后, Mono 是开源,因此您可以浏览他们的代码以了解他们如何选择实现它。显然不能保证它与微软实现的方式相同,但作为一项学术练习,任何一个都应该足够了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文