我一把动态库的方法定义在一个类中,例子如下:
using System;
using System.Runtime.InteropServices;
namespace mynamespace
{
/// <summary>
/// MyClass 的摘要说明。
/// </summary>
public class MyClass
{
public CBJClass()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
[ DllImport( "your.dll" )]
public static extern int closeport();//动态库的函数原型
                  [ DllImport( "your.dll" )]
public static extern int closeport();//动态库的函数原型
                  ........................................
}
}

解决方案 »

  1.   

    去看看这个吧
    http://expert.csdn.net/Expert/topic/2378/2378349.xml?temp=6.312197E-02
      

  2.   

    http://www.csharphelp.com/archives/archive87.html
      

  3.   

    http://expert.csdn.net/Expert/topic/2320/2320574.xml?temp=.1654627
      

  4.   

    using System.Runtime.InteropServices;public class Form1 : System.Windows.Forms.Form
    {[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
    public extern static long DeleteFile(String lpFileName);}
      

  5.   

    http://www.codeproject.com/csharp/dyninvok.asp