Problems with using external dlls (C++\CLI & DLLImport)

Hello,

I have custom DLL written on c++ which importing Lua functions and other stuff, and I trying to use this dll in my project.

I tried two ways:

  • Import functions from unity project use DLLImport attribute, but I getting: DLLNotFoundException.
  • I tried to create C++\CLI wrapper, and use them in unity project, but I got “unknown namespace” errors.

I checked all the dependencies with “Dependency Walker” and tried to put all dlls (excluding KERNEL32.dll) into project build folder, editor root folder and project sln root folder, but still getting errors.

I have Unity Pro, ver: 5.1.0f3 (Win 8.1 Pro 64x)

Dependency Walker screens:


Hey,

does LUA DLL depend on something that might not be present? Does it run outside of Unity (for example, did you try DllImport from just a console C# app)? Could you show us how you specified DllImport attribute on the function you’re trying to call?

As for C++/CLI: that is not supported and will not work in Unity.

Hi,

As you can see from first post, lua52.dll depends only on Kernel32 and Msvcr100. Yes, I wrote test-application for my dll, it runs without any errors.


Can you put the DLLs to \Assets\Plugins, and when PInvoking, don’t specify “.dll” extension (do [DllImport(“ZontWelgCore”)] and see whether it works?

First, I got an invalid architecture format (x86 instead of x64 needs by editor), after recompile to x64 I got new error:

  • Two times
  • And another one

Famous one… can you report it, this is a bug (should give you real error) :slight_smile:

It looks like you should go over all of your dlls, check their archs and set proper plugin importer settings in Unity.

1 Like