以下问题与我之前的问题相关:
将静态链接库转换为动态dll
我的第一步是开发一个dll,这已经完成。(感谢John Knoeller prakash。您的输入非常有帮助)
现在当我从我的c#应用程序中调用dll中的函数时,我会收到错误: "尝试读取或写入受保护的内存。这通常表明其他内存已损坏。" 以下是C++定义。
什么有问题?
现在当我从我的c#应用程序中调用dll中的函数时,我会收到错误: "尝试读取或写入受保护的内存。这通常表明其他内存已损坏。" 以下是C++定义。
extern "C" DEMO2_API void Decompress(char* inp_buff, unsigned short*
inp_len, char* buffer_decomp,unsigned *output_len,unsigned short* errorCode);
我的 C# 转换 p/调用
private static extern void Decompress(
byte[] inp_buff,
ref ushort inp_len,
byte[] buffer_decomp,
ref int output_len,
ref ushort errorCode
);
我如下调用它
byte[] dst = new byte[2048];
int outlen = 2048;
ushort errorCode = 0;
Decompress(src, (ushort )src.Length, dst, ref outlen,ref errorCode);
return dst;
什么有问题?