How do I marshal a structure as a pointer to a structure?

前端 未结 3 527
自闭症患者
自闭症患者 2021-01-11 18:36

I am trying to pass a structure from C# into C++ library. I pass structure as an object, and C++ function expects it as a pointer (void *).

I am having problem pas

3条回答
  •  天命终不由人
    2021-01-11 19:10

    Some additional information followup regarding @Rytmis's post.

    From https://github.com/dotnet/runtime/blob/master/docs/coding-guidelines/interop-pinvokes.md:


    Guids are usable directly in signatures. When passed by ref they can either be passed by ref or with the [MarshalAs(UnmanagedType.LPStruct)] attribute.

    [MarshalAs(UnmanagedType.LPStruct)] should only be used for by ref Guids.

提交回复
热议问题