03把IL编译成可执行文件

1、在记事本中编写IL代码如下:

.assembly HelloWorld{}
.assembly extern mscorlib{}
 
.method public static void Main(string[] args) 
{
    .entrypoint
    .maxstack 8
 
    ldstr "Hello,World"
    call void [mscorlib]System.Console::WriteLine(string)
    call valuetype [mscorlib]System.ConsoleKeyInfo [mscorlib]System.Console::ReadKey()
    pop
    ret
}

2、保存为MyFirstIL.il文件,位置在F:\学习\练习\NET之美\MyFirstIL.il

3、开始→所有程序→Microsoft Visutal Studio 2012→Visual Stuio Tools→开发人员命令提示

编译IL

4、最终把MyFirstIL.il文件编译成了MyFirstIL.exe文件。
最终

ILASM的其它用法:
ilasm new.il /output=test.exe /exe
ilasm 源文件.il /output=目标文件.dll /dll

posted @ 2014-03-12 09:20  Darren Ji  阅读(568)  评论(0编辑  收藏  举报

我的公众号:新语新世界,欢迎关注。