您的位置:首页 > 移动开发 > Unity3D

Unity Bug 修复系列

2015-08-26 10:56 501 查看


DllNotFoundException:

参考 http://stackoverflow.com/questions/10003028/dllnotfoundexception-in-unity3d-plugin-for-c-dll

最近转Windows开发,同事c++生成的dll需要引用到opencv的dll,先用dependency walker 找到依赖的库,然后把所有dll直接扔到Plugins会报DllNotFoundException,初步怀疑是加载dll的顺序不同导致的。有几种解决方案:

1、http://stackoverflow.com/questions/10003028/dllnotfoundexception-in-unity3d-plugin-for-c-dll
根据上面网站的解决方法,在Editor时把依赖的dll放到安装目录Unity\Editor文件夹下,在Build后放到与.exe同目录下。

2、http://forum.unity3d.com/threads/dllnotfoundexception-when-depend-on-another-dll.31083/
直接手动添加全局变量
public class MyPluginClass
{
static MyPluginClass()
{
String currentPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process);
String dllPath = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "Assets" + Path.DirectorySeparatorChar + "Plugins";
if(currentPath.Contains(dllPath) == false)
{
Environment.SetEnvironmentVariable("PATH", currentPath + Path.PathSeparator + dllPath, EnvironmentVariableTarget.Process);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: