How to deal with the ‘void’ in IL
If there is a method returning a object type, it invokes a method returning null. Then the ‘ldnull’ instruction should be added after the invoking instruction.The description is demonstrated as follow:
.method public hidebysig virtual instance object
Call(object[] A_1) cil managed
{
// Code size 8 (0x8)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call instance void MyDynamicProxy_TestClass1_0/__delegate__MyVoidMethod::Invoke()
IL_0006: ldnull
IL_0007: ret
} // end of method __delegate__MyVoidMethod::Call
The method will return null value.
浙公网安备 33010602011771号