DLLNotFoundException - Unity3D Plugin

10,151

Solution 1

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

Solution 2

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.

Share:
10,151

Related videos on Youtube

Keysosaurus
Author by

Keysosaurus

Updated on June 30, 2022

Comments

  • Keysosaurus
    Keysosaurus about 2 years

    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