Visual studio 2010 PinvokesTack警告如何修复它

Visual studio 2010 PinvokesTack警告如何修复它,visual-studio-2010,c#-4.0,Visual Studio 2010,C# 4.0,我正试图在我的c#应用程序中调用它 [DllImport("UOEncryption.dll")] public static extern void Decompress([In, Out] byte[] dest, byte[] src, out int dest_size, ref int src_size, ref HuffmanObj obj); [DllImport("UOEncryption.dll")] public static extern

我正试图在我的c#应用程序中调用它

    [DllImport("UOEncryption.dll")]
    public static extern void Decompress([In, Out] byte[] dest, byte[] src, out int dest_size, ref int src_size, ref HuffmanObj obj);

    [DllImport("UOEncryption.dll")]
    public static extern void DecompressClean(ref HuffmanObj obj);
c中的签名是

    void Decompress(char *dest, const char *src, int *dest_size, int *src_size, HuffmanObj *obj);
    void DecompressClean(HuffmanObj *obj);
我不知道这是怎么回事


谢谢

您忘记了[DllImport]声明中的CallingConvention属性,您的案例中是Cdecl。默认值是StdCall,它确实会触发MDA警告


HuffmanObj上的ref关键字看起来也不对,假设您将其声明为类而不是结构。请尝试调试本机代码,以便查看传递的参数值并快速发现类似的问题。项目+属性,调试选项卡,启用非托管代码调试复选框。在本机函数体的第一行上设置断点。

通过指定调用约定,问题得到解决:)非常感谢。HuffmanObj是一个结构。通过指定调用约定,问题得到解决:)非常感谢。HuffmanObj是一个结构。