Problem calling C# dll from UE4Editor (via C++/clr wraper)


Question for unreal gurus :wink: (all is on windows10, x64, ue4.14 editor, x64)
I have C++/clr dll that is loaded inside my Plugin (via call to ::LoadLibrary(“FooWraper.dll”):wink:
This dll is wraper for c# library (call it Foo.dll).

All calls in FooWraper.dll will fail until I put Foo.dll into the ENGINE directory (in the directory where UE4Editor.exe lives).
The question is WHY ?
I want the Foo.dll to be in that same place as FooWraper.dll (in MyProject\Binaries\Win64).
It’s odd to me that the system looks for it in ENGINE directory, not in in the place where FooWraper.dll lives, any ideas why this happends ?


it is because .exe directory acts like root for each project in UE, but of course isn’t good practice, so you need paste your .dll inside the plugin’s binary folder and additionally when package your game, you need tell to the editor how to include this new dll inside your build.cs of your plugin, thats for plugins, for example if you were working on game code instead plugin’s code, then you will need paste your dll here: (in MyProject\Binaries\Win64) like you say before.

hope that help

I’v ended using LoadLibraryEx & set of flags & absolute directory, to force directory searching in my director first, before any other default directories, not a pretty, but works …

If this is not a plugin then you should make a plugin wrapped around your DLL.
From there you can tell the engine and Unreal Builder Tool where it should look for the DLL files, in your plugin’s Build.cs file.