C#的写法
[DllImport("CM12Dll.dll", EntryPoint="Tdll_Submit",
     CallingConvention=CallingConvention.Winapi)] 
public  static extern int dll_Submit(int sock,ref UInt32 AMsg_id1,ref UInt32 AMSg_id2,byte Gsm_sign);

解决方案 »

  1.   

    问一下,longword是多少位,如果不是32位,那么UInt32也要进行变化。
      

  2.   

    可以给一个学习调用DLL的例子的网址吗?
    [email protected]谢谢
      

  3.   

    longword是无符号32位,照着Knight94兄的方法还是同样的错误提示。还有什么地方可能出现问题。
      

  4.   

    用这个命名空间  using System.Runtime.CompilerServices ;
      

  5.   

    难道不能用ref UInt32,你再试试下面的:
    [DllImport("CM12Dll.dll", EntryPoint="Tdll_Submit",
         CallingConvention=CallingConvention.Winapi)] 
    public  static extern int dll_Submit(int sock,IntPtr AMsg_id1,IntPtr AMSg_id2,byte Gsm_sign);
      

  6.   

    IntPtr还是不行,怎么办,不行的只能用vc写个dll封装这个函数,C#来调用这个dll
      

  7.   

    如果很急的话,先用vc.net包一个。如果你这个dll没有什么商业机密的话,给我发一分,让我试试,地址:[email protected]
      

  8.   

    我用delphi写的dll在C#中调用时也出现过这个问题:未将对象引用设置到对象的实例
    后来我发现修改delphi写的dll中的exports函数声明部分,在其后加上stdcall;
    问题就解决了,C#中调用此dll一切正常。
    你也可以去看看你的dll是否需要加上stdcall;
    祝你好运!!◎