本文介绍了我如何可以查看C#编译器生成的MSIL / CIL?为什么叫组装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的.NET C#编程。我下面几本书。据说,而不是直接将其编译为二进制code(本机code)这一点。高水平code转换成中间语言(MSIL称为又名CIL)。但是,当我编译,我得到一个EXE / DLL文件。

  1. 这是MSIL / CIL containted这些EXE / DLL文件?
  2. 我希望看到中间语言code。只是为了得到感觉到它的存在。如何看待的呢?
  3. 在他们要求此exe / dll文件的组装。他们使用这种花哨词刚刚从包含二进制code(本地code)中的exe / dll文件区分这些?
解决方案
  1. 的确是这样,更准确地在 PE的的.text 部分文件(可移植的执行= * .exe或* .dll文件)。更多信息可以在这里找到
  2. 的最佳选择是使用 ILSpy (反射不再免费)。这是一个免费的反汇编,可以dissassemble汇编成MSIL,而且C#,VB(在某种程度上)。 .NET框架SDK包含ILDASM,这是官方的MSIL dissasembler。
  3. 基本上是肯定的。程序集是一个包含MSIL code和相应的元数据文件。这并不限于PE文件本身,但是所有的当前的CLR实现使用它们。

如果我可以在这个问题上推荐一本好书太多,这是专家.NET 2.0 IL汇编塞尔Lidin。他是谁设计MSIL的人。

I'm new to .NET C# programming. I'm following few books. It is said that instead of compiling it directly to binary code (Native code). High level code is converted into intermediate language (called MSIL aka CIL). But when I compile, I get an exe/Dll file.

  1. Is this MSIL/CIL containted in these exe/dll file?
  2. I want to see that intermediate language code. Just to get feel of its existence. How to view it?
  3. They are calling this exe/dll file an assembly. Are they using this "fancy word" just to differentiate these from the exe/dll files that contain binary code (native code)?
解决方案
  1. Yes it is, more exactly in the .text section of the PE file (portable executable = *.exe or *.dll). More information can be found here.
  2. The best choice is to use ILSpy (Reflector is no longer free). It's a free disassembler that can dissassemble your assembly into MSIL but also C#, VB (to some extent). The .NET Framework SDK contains ILDasm, which is the official MSIL dissasembler.
  3. Basically yes. An assembly is a file that contains MSIL code and corresponding metadata. This is not restricted to PE files per se, but all current CLR implementations use them.

If I may recommend a good book on that matter too, it's Expert .NET 2.0 IL Assembler by Serge Lidin. He's the guy who designed MSIL.

这篇关于我如何可以查看C#编译器生成的MSIL / CIL?为什么叫组装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 20:37