【发布时间】:2011-02-24 23:41:50
【问题描述】:
我在使用 System.Reflection.Emit 和单声道导出的程序集中遇到了一个奇怪的错误。
尝试运行我的程序集时,我得到一个 InvalidProgramException: Invalid IL code。
monodis 给了我这个 CIL 结果(这与我用 Emit 导出的结果一致):
.method public static hidebysig
default void f_main (class [Pine.Core]Pine.Core.Function A_0, class [Pine.Core]Pine.Core.ValueList A_1) cil managed
{
// Method begins at RVA 0x2144
// Code size 26 (0x1a)
.maxstack 4
.locals init (
class [Pine.Core]Pine.Core.Function V_0,
class [Pine.Core]Pine.Core.IScope V_1,
class [Pine.Core]Pine.Core.ValueList V_2,
class [Pine.Core]Pine.Core.IScope V_3)
IL_0000: ldarg.0
IL_0001: stloc.0
IL_0002: ldarg.1
IL_0003: stloc.2
IL_0004: ldloc.0
IL_0005: ldftn instance class [Pine.Core]Pine.Core.IScope class [Pine.Core]Pine.Core.Function::get_Scope()
IL_000b: stloc.1
IL_000c: ldloc.1
IL_000d: newobj instance void class [Pine.Core]Pine.Core.BlockScope::'.ctor'(class [Pine.Core]Pine.Core.IScope)
IL_0012: stloc.3
IL_0013: ldloc.2
IL_0014: call instance void class [Pine.Core]Pine.Core.ValueList::Clear()
IL_0019: ret
} // end of method PineType::f_main
错误发生在IL_000b: stloc.1
我不知道为什么。
我试图用弹出指令替换stloc.1。当我这样做时,错误发生在IL_0019: ret
我真的不知道为什么会这样。有什么想法吗?
附加信息:
-
IScope是一个接口 -
BlockScope实现IScope -
Function有一个public IScope Scope { get; private set; } - Mono 2.6.7(Boehm, AMD64) 和 Mono 2.8(Boehm with typed GC and Parallel Mark, AMD64) 均出现此错误
【问题讨论】:
标签: .net exception mono cil reflection.emit