int uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
我在C#中写的代码为
[DllImport (zlib1.dll)]public static extern uncompress(Byte [] dest,uint destLen,ref Byte [] source,uint sourceLen)调用时报错“尝试读取或写入受保护的内存。 这通常指示其他内存已损坏”,网上说是参数转化有问题,请问正确的转化应该怎么写?不胜感激!

解决方案 »

  1.   

    这样:
    public static extern uncompress(Byte[] dest,ref uint destLen,Byte[] source,uint sourceLen)
      

  2.   

    露了一个:
    public static extern uncompress([In,Out]Byte[] dest,ref uint destLen,Byte[] source,uint sourceLen);
      

  3.   

    多谢,我最后是用你的public static extern uncompress(Byte[] dest,ref uint destLen,Byte[] source,int sourceLen) 成功的
      

  4.   


    编译通过了,你调用的时候返回z_OK吗?我每次都错误,要么是data error 要么是buffer error
    求解。