程序集文件在哪里



我创建了一个简单的应用程序,我在一本书中读到C#或任何.net程序被转换为包含汇编代码的汇编文件,但是我想知道在哪里可以找到该汇编文件。

所有 C# 程序(以及更一般地说,任何 .NET 语言(都转换为 .NET "程序集",这是一个包含中间字节码 - CIL 的.exe或.dll。当您通过 JIT 编译器动态运行程序时,该字节码将编译为机器语言。

默认情况下,Visual Studio 会将 .NET 程序集放在项目的 /bin 文件夹中,然后将所选配置放在该文件夹中。(默认情况下只有 2 个存在,/bin/Debug 个和 /bin/Release 个(您可以在项目属性中更改此设置。

.NET 程序集中没有程序集代码,但您可以使用 ildasm.exe 或 Mono.Cecil 等工具查看 CIL 字节码。

JIT 编译器的优点是能够检测系统的当前硬件配置,并根据 CPU 的功能应用优化。查看 JIT 生成的东西是没有意义的,因为这因计算机而异。

您需要注意术语。

.NET 二进制文件称为"程序集",它们不包含汇编代码(假设汇编代码是指实际的机器指令(。相反,它包含 CIL,它看起来类似于古怪 CPU 的汇编语言。在执行之前,CIL 被实时编译为平台的本机程序集,并运行。

如果要生成调试版本,则程序集所在的位置bin/Debug。对于发布,它处于bin/Release

请注意,这些目录是相对于您的 Visual Studio 项目位置的。

You can create two types of ASP.NET Assemblies in ASP.NET: private ASP.NET Assemblies and shared assemblies. Private ASP.NET Assemblies are created whey you build component files like DLLs that can be applied to one application. Shared ASP.NET Assemblies are created when you want to share the component files across multiple applications. Shared ASP.NET Assemblies must have a unique name and must be placed in Global Assembly Cache (GAC). The GAC is located in the Assembly directory in WinNT. You can view both the manifest and the IL using ILDisassembler (ildasm.exe).
参考:http://www.dotnet-guide.com/assemblies.html

最新更新