Amirreza Yegane
Amirreza Yegane

Reputation: 355

Unity3d DllNotFoundException is showing a directory that doesn't exist on my computer

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

image of exception

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,

DLL Import Settings

The DLL file that unity can't import also shows a warning message

dependency walker

the DLL file that can't be found in unity, in dependency walker

Upvotes: 2

Views: 3476

Answers (1)

Sunius
Sunius

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

Related Questions