为什么装配.exe文件? [英] Why is an assembly .exe file?

查看:217
本文介绍了为什么装配.exe文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大会.NET Framework是,据我所知,中间语言文件+一些元数据,清单,也许别的东西。

Assembly in .net Framework is, as I understand, intermediate language file + some metadata, manifest and maybe something else.

CLR转换装配到机器code,其可以给定的本地机器上执行。

CLR translates an assembly to the machine code, which can be executed on the given local machine.

这意味着,组件不应该由CLR被处理之前是可由机器执行。如果是这样,那么为什么它有扩展名为.exe的,这是执行在Windows机器上?

That means that assembly shouldn't be executable by the machine before being processed by CLR. If it's so, then why does it have .exe extension, which is executable on Windows machines?

推荐答案

由于Windows需要创建一个进程和.exe会做的第一件事就是为主机CLR 加载 mscoree

Since Windows needs to create a process and the first thing .exe will do is to host CLR by loading mscoree.

这是通过C# CLR:

From CLR via C#:

在Windows已经检查了EXE   文件的标头,以确定是否   创建一个32位的过程中,一个64位   过程中,或一了WoW64过程中,Windows   加载的x86,x64或IA64版本   MSCorEE.dll中到进程的地址   空间。在Windows的x86版本,   MSCorEE.dll中的x86版本可以   \ Windows \ System32下:在C中   目录。在基于x64或IA64版本   Windows的x86版本的   MSCorEE.dll中可以在找到   C:\ WINDOWS \ SysWow64文件目录,   而64位版本(64或   IA64)可以在找到   C:\ Windows \ System32目录(用于   向后兼容的原因)。然后,   进程的主线程调用   方法定义里面MSCorEE.dll中。   此方法初始化CLR,负载   该EXE程序集,然后调用它的   入口点方法(主)。在这   点,托管的应用程序已启动   并运行。

After Windows has examined the EXE file's header to determine whether to create a 32-bit process, a 64-bit process, or a WoW64 process, Windows loads the x86, x64, or IA64 version of MSCorEE.dll into the process's address space. On an x86 version of Windows, the x86 version of MSCorEE.dll can be found in the C:\Windows\System32 directory. On an x64 or IA64 version of Windows, the x86 version of MSCorEE.dll can be found in the C:\Windows\ SysWow64 directory, whereas the 64-bit version (x64 or IA64) can be found in the C:\Windows\System32 directory (for backward compatibility reasons). Then, the process' primary thread calls a method defined inside MSCorEE.dll. This method initializes the CLR, loads the EXE assembly, and then calls its entry point method (Main). At this point, the managed application is up and running.

这篇关于为什么装配.exe文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆