您的位置:首页 > 编程语言 > C#

c# il (中间代码)exe,dll(编译成的程序) 之间的转换

2011-02-18 11:12 2181 查看
il 转换成dll 和 exe 用的是ilasm
exe dll转换成 il 用的是 ildasm

ilasm 和 ildasm 在 C:/WINDOWS/Microsoft.NET/Framework/v1.* 后v2.* 下有 微软提供

(1)ilasm示例:
下面的命令对 MSIL 文件 myTestFile.il 进行汇编并产生可执行文件 myTestFile.exe。
ilasm myTestFile
下面的命令对 MSIL 文件 myTestFile.il 进行汇编并产生 .dll 文件 myTestFile.dll。
ilasm myTestFile /dll
下面的命令对 MSIL 文件 myTestFile.il 进行汇编并产生 .dll 文件 myNewTestFile.dll。
ilasm myTestFile /dll /output:myNewTestFile.dll
(2)ildasm示例
下面的命令使 PE 文件 MyHello.exe 的元数据和反汇编代码显示在 Ildasm.exe 的默认 GUI 中。
ildasm myHello.exe
下面的命令对 MyFile.exe 文件进行反汇编,并将结果 MSIL 汇编程程序文本存储在 MyFile.il 文件中。
ildasm MyFile.exe /output:MyFile.il
下面的命令对 MyFile.exe 文件进行反汇编,并将结果 MSIL 汇编程序文本显示到控制台窗口中。

ildasm MyFile.exe /text

如果文件 MyApp.exe 包含嵌入的托管和非托管资源,则下面的命令将产生以下 4 个文件:
MyApp.il、MyApp.res、Icons.resources 和 Message.resources:

ildasm MyApp.exe /output:MyApp.il
下面的命令对 MyFile.exe 的 MyClass 类中的 MyMethod 方法进行反汇编,并将输出显示到控制台窗口中。

ildasm /item:MyClass::MyMethod MyFile.exe /text
在上面的示例中,可能有几个具有不同签名的 MyMethod 方法。
下面的命令对返回类型为 void 且带有参数 int32 和 System.string 的 MyMethod 方法进行反汇编。

ildasm /item:"MyClass::MyMethod(void(int32,class System.String))" MyFile.exe /text

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  dll exe c# 汇编 class 存储
相关文章推荐