两种在“项目”菜单中,一种在代码中引用。
方式一:使用 NuGet 包管理器
方式二:添加引用
方式三:使用 DllImport 特性引入
这种dll里面只有一个方法,跟上面两种dll不同。
【引用步骤】
首先将非托管 DLL 复制到项目根目录中的bin/Debug下。
然后在代码中引用dll中定义的函数YourFunction。
using System.Runtime.InteropServices;
public class MyClass
{
[DllImport("YourUnmanagedDll.dll")]
public static extern void YourFunction();
}