Mono.Cecil: operation may destabilize at runtime

I followed the prompts here , I even entered the following lines:

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

I have two properties in two classes:

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

and

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

The generated IL code is completely identical, except, of course, the name of the properties and the type of the support field. But the first one throws a VerificationException ("An operation can destabilize runtime"), the second doesn't. What could I do wrong?

edit: here is an abusive 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 } 
+4
source share
1 answer

Nothing.:)

  L_001b: box int32 

There is a solution.

+3
source

Source: https://habr.com/ru/post/1336455/


All Articles