2011-01-21 52 views
4

动摇我跟着提示here,我甚至把以下行:Mono.Cecil能:操作可以在运行时

var MSILWorker = prop.SetMethod.Body.GetILProcessor(); 
MSILWorker.Body.InitLocals = true; 

我有两个类的两个属性:

[NotifyProperty] 
public int Number { get; set; } 

[NotifyProperty] 
public string Name { get; set; } 

生成的IL代码是完全相同的,除了当然在名称的属性和d后台字段的类型。然而,第一个抛出了VerificationException(“操作可能会破坏运行时的稳定性”),第二个不会。 我可能做错了什么?

编辑:这里是有问题的IL:

.method public hidebysig specialname instance void set_Number(int32 'value') cil managed 
{ 
    .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() 
    .maxstack 3 
    L_0000: nop 
    L_0001: ldarg.0 
    L_0002: ldarg.1 
    L_0003: stfld int32 TestApplication.SLTest.SLBOComposite::<Number>k__BackingField 
    L_0008: ldarg.0 
    L_0009: ldstr "Number" 
    L_000e: call instance void TestApplication.SLTest.SLBOComposite::RaisePropertyChanged(string) 
    L_0013: nop 
    L_0014: ldarg.0 
    L_0015: ldstr "Number" 
    L_001a: ldarg.1 
    L_001b: call instance void W3B.TestApplication.SLTest.SLBOComposite::Validate(string, object) 
    L_0020: nop 
    L_0021: ret 
} 

回答

3

没关系。 :)

L_001b: box int32 

有解决方案。

相关问题