The problem is that you're using the overload of Emit()
that takes an int
, but ldc.i8
requires a long
.
So, if you use the following line, your code will work fine (note the 0L
literal instead of 0
):
defaultConstructorIL.Emit(OpCodes.Ldc_I8, 0L);