How can I marshall a vector from a C++ dll to a C# application?

前端 未结 3 996
名媛妹妹
名媛妹妹 2020-12-10 06:26

I have a C++ function that produces a list of rectangles that are interesting. I want to be able to get that list out of the C++ library and back into the C# application th

3条回答
  •  盖世英雄少女心
    2020-12-10 06:48

    I'm pretty sure you can't do this. You have to be able to translate the C++ code directly to a C# class, so you would at least have to replicate the internals of the vector class to marshall it correctly. I'm also pretty sure you won't be able to move references across the boundary, you'll have to use IntPtr (raw pointers). The approach that i know works is to marshall a raw array of the structs.

提交回复
热议问题