其他语言写的dll: class xxxx { [DllImport("xxx.dll")] public static external int xxxxxx(); public int RevokeDllMethod() { return xxxxxx(); } }
How to create a DLL library in C and then use it with C# 14 Mar 2005 An easy-to-use example of how to create a DLL library in C and then use it with C#. http://www.codeproject.com/csharp/UseCDLLlibinCS.asp
在项目的“引用”中添加该dll文件的引用,然后在页面using+dll中的命名空间,代码中就能使用里面的方法了
如果是 .NET 程序集或是 Com,ActiveX之类的,直接添加引用就可以了
如果是普通Dll或API,这要用DllImportAttribute在运行时动态引入
然后在每个需要的类中写上using 这个dll的命名空间
就可以了
class xxxx
{
[DllImport("xxx.dll")]
public static external int xxxxxx(); public int RevokeDllMethod()
{
return xxxxxx();
}
}
14 Mar 2005
An easy-to-use example of how to create a DLL library in C and then use it with C#. http://www.codeproject.com/csharp/UseCDLLlibinCS.asp