As far as I know, the minimum size of an object is 4 bytes (the size of a
plain System.Object value). You could try setting it to that value, and see
if PEVerify still complains.

2011/7/22 Kenneth Skovhede <[email protected]>

> Thanks, after setting ClassSize = 0 I get:
> [MD]: Error: Value class has neither fields nor size parameter.
> [token:0x02000002]
> [MD]: Error: ClassLayout has invalid PackingSize; valid set of values is
> {1,2,4,...,128} (parent: 0x02000002; PackingSize: 65535). [token:0x00000001]
>
> Setting PackagingSize = 0 removes the second error, but PEVerify still
> complains about with:
> [MD]: Error: Value class has neither fields nor size parameter.
> [token:0x02000002]
>
> I'm guessing that size=0 is not allowed, even for a struct with no data,
> or being handled incorrectly by the Cecil emitter.
>
> My fix is to locally set:
> type.ClassSize = type.PackingSize =
> (short)System.Runtime.InteropServices.Marshal.SizeOf(typeof(IntPtr));
>
> I'm not sure how much overhead this will cause, but presumably this will
> take up 4/8 bytes of stack space for each call.
>
> Regards, Kenneth
> --
> --
> mono-cecil

-- 
--
mono-cecil

Reply via email to