小编Mik*_*ved的帖子

Writing packed structs with a MemoryMappedViewAccessor bug?

I have a struct that is defined with Pack=1 and it is 29 bytes long. If it is not packed, it would be 32 bytes long.

  • Marshal.SizeOf(TypeOf(StructName)) returns 29.

  • StructName struct; sizeof(struct) returns 32.

When I write that struct out using MemoryMappedViewAccessor it writes out 32 bytes, NOT 29 bytes.

So, short of marshalling the struct to a byte array and writing it out that way, is there any way to get it to write out that struct correctly?

More …

c# struct marshalling memory-mapped-files

7
推荐指数
1
解决办法
3644
查看次数

标签 统计

c# ×1

marshalling ×1

memory-mapped-files ×1

struct ×1