设置程序Dlls的搜索路径
1.导入Native函数
/// <summary>
/// 设置Dlls的搜索路径
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool SetDllDirectory(string path);
2.在引入包装类中设置相应的Dlls的搜索路径
var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
path = Path.Combine(path, Environment.Is64BitProcess ? "x64" : "x86");
SetDllDirectory(path);