structoffset attribute can only be placed on members of type marked with the structlayout(LayoutKind.Explicit)
The structoffset attribute can only be used in structures that require explicit layout information.
The following sample generates CS0636:
using System; using System.Interop; [structlayout(LayoutKind.Sequential)] struct Worksheet { [structoffset(4)]public int i; // CS0636 // try the following line instead // public int i; } public class MainClass { public static void Main () { } }