Critical error detected c0000374 - C++ dll returns pointer off allocated memory to C#

后端 未结 3 1422
一个人的身影
一个人的身影 2021-02-07 18:33

I have a c++ dll which serving some functionality to my main c# application. Here i try to read a file, load it to memory and then return some information such as the Pointer to

3条回答
  •  没有蜡笔的小新
    2021-02-07 19:16

    You are allocating the output data 2 times. Once in C# as new IntPtr and then in C++ as GlobalAlloc and then return the Pointer Returned by GlobalAlloc. So the Pointer returned by new intPtr has been lost.

提交回复
热议问题