主要代码如下:                 [DllImport("MwNetGate.dll")]
public static extern int ConnectOpen(
string Uid, 
string Password, 
string ServerIP, 
int ServerPort
);                  private void button1_Click(object sender, System.EventArgs e)
{
if (ConnectOpen("xxxxxxxxxxxx", "xxxxxxx", "61.242.89.115", 8018) == 0)
{
MessageBox.Show("ConnectOK");
}
else
{
MessageBox.Show("ConnectERR");
}
}编译通过, button1_Click时报错如下:
其他信息: 无法在 DLL MwNetGate.dll 中找到名为 ConnectOpen 的入口点。此DLL我在ASP下运行正常!!!!

解决方案 »

  1.   

    在C#里如何调用标准DLL函数
    在C#里只需要调用PInvoke (Platform Invocation) 服务。C# 支持一种sysimport属性
    支持这种调用。
    下面是完整的语法形式(在例子里没有用到所有的参数):[sysimport(
    dll=dllName,
    name=functionName,
    charset=characterSetToBeUsed)
    ]给出一个调用Win32 MessageBox函数的例子:using System;class pinvokeClient
    {
    [sysimport(dll="user32.dll")]public static extern int MessageBoxA(int hwnd, string message,
    string caption, int type);public static void Main()
    {
    int result = MessageBoxA(0, "Hello World", "PInvoke Test", 0);
    }
    }
      

  2.   

    多谢  karykwan(独行者)
             public class Win32
    {
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    public static extern int MessageBox(
    int hWnd, 
    String text,
    String caption, 
    uint type);
    }
              private void button2_Click(object sender, EventArgs e)
    {
    Win32.MessageBox(0, "Hello World", "Platform Invoke Sample", 0);
    }我试过这样是OK的,但是我的那个DLL就会报错说找不到入口点,DELPHI编译的DLL和user32.dll有什么区别没有?
      

  3.   

    那如何查看一个DLL文件的入口函数有哪些啊?
      

  4.   

    我想借贵宝地问一下问题,dll(delphi的)里面有一个窗体,我想把它调出来,显示在c#的一个panel上怎么办?
      

  5.   

    以前也有过类似的情况,
    要设置一下编译器的选项,把调用dll方式从C语言方式改为标准方式VS与Delphi编译dll不一样的
      

  6.   

    可能是dll格式不对如果安装c++ builder 可以用tdump xx.dll 1.txt 
      

  7.   

    你写的dll文件应该是vcl的而非com,所以在c#中不可调用,我现在是遇到这种情况,但是还不知道怎么解决呢,郁闷.
      

  8.   

    你写的dll文件应该是vcl的而非com,所以在c#中不可调用,
    ----------------------------------------------------
    连什么是dll都搞不清楚. vcl与dll有什么关系吗? 
    只要是在windows平台下,dll 格式是相同的. 不一定要编译成com形式也可以调用.应该是你声明的参数或其类型与dll里的不符合 (如果你在asp下运行正确的话)
    要么就没有这个入口函数.
      

  9.   

    现在我是将DLL在服务端注册
    用VB。NET调用如下调用
    Dim monGate As Object
    monGate = CreateObject("MwNetGate.OneWayInterface")
    .
    .
    .
    程序就可以编译使用了,不知道为什么会这样
      

  10.   

    从托管应用程序调用非托管代码
    当调用用户定义的 DLL 中所包含的函数时,有必要将 extern "C" 添加在 DLL 函数声明之前,如下所示:
    The function declaration in SampleDLL.h file
    extern "C" SAMPLEDLL_API int fnSampleDLL(void);详见http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vccore/html/vcwlksysimportattributetutorial.asp但愿有用!
      

  11.   

    C形式的标示和C++形式的标示不一样?
    可以用dependency walker看看。