.net - Windows 如何区分常规 EXE 和 .NET exe?

标签 .net windows

我在一次采访中被问及 Windows 操作系统如何区分常规 EXE 和 .NET EXE。

我的回答是,当构建 .NET exe 时,编译器会将一些信息放入 header 中。信息为PE32或PE32+。 Windows 验证 header 以确定它是否需要加载加载 CLR 并执行 EXE 的 MSCOREE.dll。

我的回答正确吗?

最佳答案

我认为以下两个链接是了解 PE 文件结构和 Windows 加载程序的良好资源。

2002 年 3 月那篇文章的确切引述是:

The primary purpose of a .NET executable is to get the .NET-specific information such as metadata and intermediate language (IL) into memory. In addition, a .NET executable links against MSCOREE.DLL. This DLL is the starting point for a .NET process. When a .NET executable loads, its entry point is usually a tiny stub of code. That stub just jumps to an exported function in MSCOREE.DLL (_CorExeMain or _CorDllMain). From there, MSCOREE takes charge, and starts using the metadata and IL from the executable file. This setup is similar to the way apps in Visual Basic (prior to .NET) used MSVBVM60.DLL.

关于.net - Windows 如何区分常规 EXE 和 .NET exe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2638883/

相关文章:

c# - 任何现成的 C# 基数排序实现?

c# - 在循环中创建的分隔字符串

c# - 为什么调用 Dispose?

windows - 使用 CMake : Missing moc, uic、rcc 查找 Qt

windows - 如何打开 Windows 资源管理器并将文件路径保存到 Matlab 中的文本框?

c# - 使用 (LINQ/Predicate) 将 DataTable 的所有列名放入字符串数组

c# - "Token?"的确切定义是什么

c# - msbuild 中的默认平台

windows - 我可以让 emacs grep windows 只使用另一个窗口打开文件吗?

Windows API : write to screen as on screen display