I have a structure that has a non-overlapping field reported as overlapping.
[FieldOffset(8)] Int32 X; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] [FieldOffset(12)] string Y; [FieldOffset(28)] int Z;
Reported error:
Cannot load type "XXX" ... it contains an object field with an offset of 12, which is incorrectly aligned or overlapped by a field other than the object.
This only happens in the Release configuration (TRACE, DEBUG and unsafe code flags are enabled, optimization is disabled), fortunetelling - what happens to it?
UPD: thanks @svick. Confirmed that the x64 build is not intended for sorting.
-, Release . Target Target: x64, , x86, .
, , FieldOffset struct ( ), MarshalAs .
FieldOffset
struct
MarshalAs
- 12. .Net( 4 32- 8 64-), , 64-.
, , , : .
x86. , , .
@svick , , , CLR . 64- , 12 . . , CLR, .
, , 32- , Debug, Release. . , Release.
64- , fixed char[16].
fixed char[16]
I think the default alignment of data fields in your system is 8 bytes. You must use offset 16 for Y.