C#在调用C++的接口时,经常出现这样的错误:尝试读取或写入受保护的内存。这通常指示其他内存已损坏。 Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 其原因就是在在调用C++接口时,C#中参数务必要分配给它们内存。 比如在C++中的接口为 bool getUserName(int userID,ref string userName) 则在C#中声明string userName = new string(' ',50),然后再调用 getUserName(123,userName )即可。
C#调用C++接口的bug
最新推荐文章于 2021-05-11 15:36:23 发布