DLLNotFoundException - Unity3D Plugin

2019-01-25 22:53发布

I'm getting a DLLNotFoundException in standalone builds on some windows machines, others work perfectly. Dll file is definitely in the plugins folder, copied it to the projectName_Data folder too but no difference.

Also attempted to add dll to streaming assets folder and set new path (Environment.SetEnvironmentVariable) as above but that didn't work either.

Using Unity 4.5.5 btw

Any help at all would be greatly appreciated!!!

DLLNotFoundException

2条回答
Viruses.
2楼-- · 2019-01-25 23:04

I discovered that the problem was that players needed Visual C++ redistributable installed, which can be downloaded here: https://www.microsoft.com/en-gb/download/details.aspx?id=40784

查看更多
beautiful°
3楼-- · 2019-01-25 23:21

What I found is that the error DllNotFoundException is, in some circumstances, very misleading. Unity is not to blame for this because when something goes wrong with dll loading, Unity simply doesn't have that dll in memory and tells you so.

As Keysosaurus says, Visual C++ Redistributable must be installed for your standalone version to work and in most cases this solves the trouble but there can be other reasons like third party dependencies.

In case you are using third party libraries then you must also copy all the needed DLLs or SOs to your executable's folder.

For example I am working with OpenNI 2 and when I build I immediately copy all files from C:\Program Files (x86)\OpenNI2\Redist folder to the folder that contains the .exe. Not doing this results in DllNotFoundException.

Also don't forget that DLLs (and SOs) must match the architecture you are targeting so if you are targeting x64 (64 bit) then your DLL must be x64 too and if you try to use a x86 (32 bit) DLL Unity will be confused and will not load that giving you the same error.

As a side note bear in mind that Unity 5 comes both in 32 and 64 bit versions. In order to run your game in Unity Editor, all third party libraries must be present in both x86 and x64 (in Unity's conventional folders) or at least the one that matches you Unity Editor's architecture.

查看更多
登录 后发表回答