Ok, I thought about it after posting. I really read the error message incorrectly. This, in fact, has nothing to do with the inherited base class.
When I created the type, I specified the attribute "TypeAttributes.ExplicitLayout", which is required. Unfortunately, I did not understand that I had to add an offset to each field when I created them. The exception message was completely accurate. Sorry for the false alarm. The corrected code follows:
public class SourceClass { public Int32 first = 1; public Int32 second = 2; public Int32 third = 3; } public static class MyConvert { public static object ToDynamic(object sourceObject, out Type outType) { Int32 fieldOffset = 0;
EDIT: The above code will not work. The field index is in bytes, so when you increase the offset, you should do this to fit the field as follows:
fieldOffset += sizeof(Int32);
source share