Correct way to import 3rd party dlls into Unity?

Hi,

In our project, we are trying to import TeamSpeak dlls to use functions from the dlls. Something like this:

class ts3client
{
    [DllImport("ts3client_win32.dll", EntryPoint = "ts3client_initClientLib")]
    public static extern uint ts3client_initClientLib(ref client_callback_struct arg0, ref client_callbackrare_struct arg1, LogTypes arg2, string arg3);

    public static void ShowPath()
    {
        Debug.Log("Here: " + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase));
    }
}

// Somewhere
uint error = ts3client.ts3client_initClientLib(ref cbs, ref cbs_rare, LogTypes.LogType_FILE | LogTypes.LogType_CONSOLE, null); --> ERROR: DllNotFoundException: ts3client_win32.dll

However, we are not sure where we should copy those dlls in order to let Unity recognize and import them. We keep receiving “DllNotFoundException: ts3client_win32.dll”.

I tried to copy dlls into “Assets”, “Assets/Resources” folder, also “Library/ScriptAssemblies” (as a test result from above ShowPath function)… but Unity doesn’t seem to recognize the dlls.

Is there any suggestion for this?

Put directly called DLL’s in your “Assets/Plugins” folder.
For all indirectly called DLL’s place in your Unity.exe root directory.

Thanks for your reply. I tried to put the dll (ts3client_win32.dll) everywhere I think possible but still receive the error…

In our project folder:

  • Assets
  • Assets\Plugins
  • Assets\Resources
  • Library\ScriptAssemblies

In Unity installation folder:

  • Editor
  • Editor\Data\Frameworks
  • Editor\Data\Frameworks\WindowsPlayer
  • Editor\Data\Frameworks\Mono.framework
  • Editor\Data\MonoCompiler.framework
  • Editor\Data\lib
  • Editor\Data\unity

…

Putting Dll in project root folder seems to work. Using gmer, I can see Unity loaded ts3server_win32.dll as expected. But the funny thing is ts3client_win32.dll still seems to be unrecognizable though it’s in the same folder as ts3server_win32.dll… Will try to figure out this later…

The problem in this case turned out to be TeamSpeak library. Please refer to this article for more details and fix in case you need to solve the same problem.
http://web.ist.utl.pt/joao.costa.fernandes/?p=965

This is rather an old issue, though does anyone by any chance remember how to resolve it? The link provided unfortunately does not contain the information anymore.

I am getting issues with teamspeak on mac. Link to that is here :
http://forum.unity3d.com/threads/219375-Teamspeak-Mac-Dllnotfoundexception-ts3client_win32?p=1464157#post1464157

I have issues with the unity installation after downloading the hub, please can i have someone send the current unity 2019 3.0a6 “or a webpage i can download it from” sent to me so that i can install it manually please?? I would really appreciate, i have a wonderful project in mind, but with this challenge it’s difficult.

Here is the first 2 minute of this video explain how to add NUGET or third party dll in unity