DynamicMethod NullReferenceException
Posted
by Jeff
on Stack Overflow
See other posts from Stack Overflow
or by Jeff
Published on 2010-03-12T17:40:30Z
Indexed on
2010/03/12
17:57 UTC
Read the original article
Hit count: 343
Can anyone tell me what's wrong with my IL code here?
IL_0000: nop
IL_0001: ldarg.1
IL_0002: isinst MyXmlWriter
IL_0007: stloc.0
IL_0008: ldloc.0
IL_0009: ldarg.2
IL_000a: ldind.ref
IL_000b: unbox.any TestEnum
IL_0010: ldfld Int64 value__/FastSerializer.TestEnum
IL_0015: callvirt Void WriteValue(Int64)/System.Xml.XmlWriter
IL_001a: nop
IL_001b: ret
I'm going crazy here, since I've written a test app which does the same thing as above, but in C#, and in reflector the IL code from that looks just like my DynamicMethod's IL code above (except my test C# app uses a TestStruct with a public field instead of the private value field on the enum above, but I have skipVisibility set to true)...
I get a NullReferenceException.
My DynamicMethod's signature is:
public delegate void DynamicWrite(IMyXmlWriter writer, ref object value, MyContract contract);
And I'm definitely not passing in anything null.
Thanks in advance!
© Stack Overflow or respective owner