Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

native DLL cannot be loaded

Discussion in 'Scripting' started by poisonnuke, Aug 13, 2018.

  1. poisonnuke

    poisonnuke

    Joined:
    Nov 22, 2016
    Posts:
    82
    Hello,

    Ive searched the forums and tried some of the tips, like placing the DLL in a Plugins directory, or with x86 and x64 subdirectories for the different version or directly in the Assets-root. I have enabled the unsafe compile option in the player options and tried the "InitilializeOnLoad" for the static class, which loads the DLL.

    But nothing helps.

    If one would want to try out, it is the PCANBasic.dll for the Peak PCAN-USB adapter, included over the PCANBasic.cs (you actually dont need the driver installed to test if you can call any of the external routines).

    Any ideas on that?
     
  2. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    What's the platform and architecture it's been compiled for? Have you set the settings appropriately? What's the exact error message?
     
  3. poisonnuke

    poisonnuke

    Joined:
    Nov 22, 2016
    Posts:
    82
    compiled for standalone on a x64 Win7 platform.

    Its a simple "DLLNotFoundException", cant see any additional informations on that. But this already comes when playing in the editor.
     
  4. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    It probably has a dependency on another DLL that also needs to be included. DLL error messages are frustratingly vague like that.
     
  5. poisonnuke

    poisonnuke

    Joined:
    Nov 22, 2016
    Posts:
    82
    They provide an example VS project and I only need to copy that single DLL into the project-folder to make it work. Is there a way inside a working project to trace down the dependencies?
     
  6. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    In that case, add it to the project folder (not into Assets, but on the same level). Entering playmode in the editor, the engine will usually check that location for assembly that cannot be found using other paths.

    If the build does not work either, you have to make sure that the .dll has actually been copied over to the executables folder, too. If it isn't there, add it there as well.
     
  7. poisonnuke

    poisonnuke

    Joined:
    Nov 22, 2016
    Posts:
    82
    thank you, that is working!