Reputation: 355
I'm trying to use an asset in my unity project, it has a c# script.cs that calls and initializes the plugins, when the game starts. but when I press the play button, unity keeps throwing DllNotFoundException
this is the picture of the error i get when i play the game (sorry, i had to send a picture and censor some parts, because of the term of use i signed)
the error says
at "C:/Users/thatcompany/source/repos/plugin-name/plugin-name-api/a-class-in-plugin.cs:192"
and this path doesn't even exist on my computer
this asset is for unity3d and is written in c# and c++. the code that is used for initialization is written in c#, it uses a DLL file which is also written in c#, and that DLL file uses another DLL file which is written in c++ and has
[DllImport("DllThatUnityCantFind", EntryPoint = "name_initialize", CharSet = CharSet.Ansi)]
public static extern IntPtr Name_initialize(int argc, string[] argv);
this is the only line of code that I found useful for this question, as the other lines don't even get a chance to get executed.
I've have read all of the related questions on this website and others and tried these answers,
putting DLL files in the root of the project
putting DLL files in unity editor main folder
separating DLL files into different directories
putting dependant DLL files into the root of the project while having the other one in the plugin folder and visa versa
switching Scripting Runtime Version to 3.5 and 4.x
changing API capability Level
making a new project
restarting the editor
opening the unity editor as administrator
updating unity to the version that this plugin is tested on
updating unity to the latest version
changing name of the DLL file to name.dll.dll instead of name.dll
changing the platform setting of the plugin
installing all the different versions of VC redist 2005-2019, 32 and 64 bits
The DLL file that unity can't import also shows a warning message
the DLL file that can't be found in unity, in dependency walker
Upvotes: 2
Views: 3476
Reputation: 2907
That DLL links against VS 2015 debug runtime (MSVCP140D.dll). Unless Visual Studio 2015 with C++ workload is installed on your machine, the DLL will not load.
This is a bug in the .DLL - DLLs that get distributed should not be compiled against debug C++ runtime. I suggest contacting the person you got this DLL from and ask them to rebuild it in "Release" config. While you're at it, you might also want to ask them to link CRT statically, as otherwise you'll have to have VS 2015 C++ redistributable package installed on the machine you're trying to use that DLL on.
Upvotes: 3