Search Unity

DLL not found with standalone app but works fine in editor

Discussion in 'Windows' started by shebiao, Mar 2, 2016.

  1. zubair_saqib

    zubair_saqib

    Joined:
    Sep 21, 2014
    Posts:
    11
    Hello, I have sent you the project in the PM, please have a look.
     
  2. Reeley

    Reeley

    Joined:
    Feb 23, 2017
    Posts:
    45
    I´m having the same problem DLLNotFoundException.

    Unity: 2018.4.3f1
    Scripting Runtime: 4.x
    API Compatibility Level: 4.x

    Im using a DLL to communicate over CAN with this adapter https://www.peak-system.com/PCAN-USB.199.0.html?&L=1

    The dll does not work for both standalone and editor. Copying the dll to the project root will make it work in the editor and copying besides the .exe will make it work in standalone.

    I have a project set up and can send it to you or file a bug report.
     
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    What exact error are you getting? The project you sent me doesn't produce any DllNotFoundExceptions. It just pops up a printer dialog when I press a space bar.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    If copying the DLL next to the .exe makes it work, it's definitely a bug. Can you file a bug report please?
     
  5. Reeley

    Reeley

    Joined:
    Feb 23, 2017
    Posts:
    45
    Filed a bug report (Case 1172323)
     
  6. Reeley

    Reeley

    Joined:
    Feb 23, 2017
    Posts:
    45
    Response from QA:

    I will test this once i get my hands on 2019.2
     
  7. zubair_saqib

    zubair_saqib

    Joined:
    Sep 21, 2014
    Posts:
    11
    When your PC has a scanner connected to it and you run the project in editor and press space bar it will scan the document with the scanner and show you the scanned document in the unity image in the scene but when you make a standalone build and try to do the same the project just close it self when you press space bar. And the problem is it just straight up crashes and does not give you any error or any logs, while in editor it just works perfectly.


    Here is the call stack when I attached the build with the Visual studio to get the logs.

     
    Last edited: Jul 29, 2019
  8. Reeley

    Reeley

    Joined:
    Feb 23, 2017
    Posts:
    45
    Editor is fixed, standalone still not working

    Tested with 2019.2.0b10
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    That is very different from DllNotFoundException being thrown. You need to report a bug on this.
     
  10. Cosmonaut72

    Cosmonaut72

    Joined:
    Nov 16, 2017
    Posts:
    9
    We are having a similar issue with SQLite.Interop.DLL.
    We have our own managed library that refers to System.Data.SQLite.dll (which in turn has a dependency on the interop file)
    Running in the editor is fine and everything works and logs correctly.
    On build we receive the error

    Fallback handler could not load library D:/snobal-xr/src/xr/unity/xr-app/Build/Snobal_Data/Mono/SQLite.Interop.dll
    and a few other derivatives of this

    The interop dll is found within build/myapp-data/plugins and there is no mono folder.
    Both creating a mono folder manually and moving the dll, as well as copying the DLL to the root build folder worked.

    We have the solution of writing a build script that will automatically do this task, however it is very hacky solution and I don't like it personally. It is not good for production.

    Is there any new news on this issue?
    Unity version 2019.1.11f1
     
  11. Reeley

    Reeley

    Joined:
    Feb 23, 2017
    Posts:
    45
    I just got an email which stated:

    It's now fixed in Unity 2019.2.2f1, 2019.3.0a12, 2020.1.0a1 and above.​

    I did not test this though.
     
  12. Amir-Ward

    Amir-Ward

    Joined:
    Jan 26, 2015
    Posts:
    30
    I have the exact same problem after upgrading to 2019.2.5f1. For some reason the dll's are being placed outside of the x86_64 folder in game_Date/Plugins folder: upload_2019-9-18_9-40-21.png

    No matter what import settings I choose or what folder in Plugins I put the libs in it just won't go into the x86_64 folder in the build causing the missing DLL errors. If I manually move them everything works fine. Any help?
     
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you show the plugin importer configuration?
     
  14. Amir-Ward

    Amir-Ward

    Joined:
    Jan 26, 2015
    Posts:
    30
    @Tautvydas-Zilys

    upload_2019-9-18_15-43-53.png

    I've also tried putting into Plugins/x86_64 folder as well
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I’ll investigate. Which unity version did you upgrade from?
     
  16. Amir-Ward

    Amir-Ward

    Joined:
    Jan 26, 2015
    Posts:
    30
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hey so I can definitely reproduce it that it's being placed in a different folder (I don't know why - I'll find out). However, my P/Invokes into the library still succeed. Could you report a bug if your P/Invokes fail?
     
  18. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    This bug is pretty weird I couldn't reproduce it in clean project but I've finally found the issue.

    DllImport (and prob P/Invoke) fails only when folder "x86_64" exists in Plugins folder (in build). I'm not sure but It may happen only in IL2CPP builds. What's weirder is that it started working after changing to Mono and than to il2cpp. To break it once again I had to restart Unity and delete Library folder.

    Reproduce steps:
    1. Make project
    2. Add: https://github.com/discordapp/discord-rpc
    3. Follow Unity setup for windows
    4. Add the example dll usage class https://github.com/discordapp/disco...es/button-clicker/Assets/DiscordController.cs
    5. Add this to any object on the scene
    6. Build for x86_64 with IL2CPP
    7. Make empty folder <project_name>_Data\Plugins\x86_64
    8. Open game and check log file.

    Or:
    1. Get project from report bug 1185926
    2. Continue from step 6. above


    Workaround until fix:
    1. Cut-Paste everything from "x86_64" to parent Plugin folder
    2. Remove empty "x86_64" folder
     
    Last edited: Sep 22, 2019
  19. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    Better fix:

    These settings will put dll to the Plugins/x86_64 folder:


    These settings will put dll to Plugins folder:


    So check x86_x64 for every dll to prevent x86_64 folder from being created
     
  20. nakkalokesh99

    nakkalokesh99

    Joined:
    Jul 19, 2017
    Posts:
    7
    Android Build working Perfectly when using Mono.
    When using IL2CPP There is An Error In Android Device

    DllNotFoundException: Unable to load DLL 'MonoPosixHelper': The specified module could not be found.

    zipsharp.NativeZip.zipOpen2_32 (System.String pathname, System.Int32 append, System.IntPtr globalcomment, zipsharp.ZlibFileFuncDef32& pzlib_filefunc_def) (at <00000000000000000000000000000000>:0)
    zipsharp.NativeZip.OpenArchive32 (zipsharp.ZlibFileFuncDef32 funcDef, zipsharp.Append append) (at <00000000000000000000000000000000>:0)
    zipsharp.ZipArchive..ctor (System.IO.Stream stream, zipsharp.Append append, System.Boolean ownsStream) (at <00000000000000000000000000000000>:0)
    System.IO.Packaging.ZipPackage.FlushCore () (at <00000000000000000000000000000000>:0)
    System.IO.Packaging.Package.Flush () (at <00000000000000000000000000000000>:0)
    System.IO.StreamWriter.Dispose (System.Boolean disposing) (at <00000000000000000000000000000000>:0)
    System.IO.StreamWriter.Close () (at <00000000000000000000000000000000>:0)
    System.Xml.XmlTextWriter.Close () (at <00000000000000000000000000000000>:0)
    System.IO.Packaging.Package.WriteRelationships (System.Collections.Generic.Dictionary`2[TKey,TValue] relationships, System.IO.Stream stream) (at <00000000000000000000000000000000>:0)
    System.IO.Packaging.Package.CreateRelationship (System.Uri targetUri, System.IO.Packaging.TargetMode targetMode, System.String relationshipType, System.String id, System.Boolean loading) (at <00000000000000000000000000000000>:0)
    System.IO.Packaging.Package.CreateRelationship (System.Uri targetUri, System.IO.Packaging.TargetMode targetMode, System.String relationshipType) (at <00000000000000000000000000000000>:0)
    DocumentFormat.OpenXml.Packaging.OpenXmlPackage.CreateRelationship (System.Uri targetUri, System.IO.Packaging.TargetMode targetMode, System.String relationshipType) (at <00000000000000000000000000000000>:0)
    DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AttachChild (DocumentFormat.OpenXml.Packaging.OpenXmlPart part, System.String rId) (at <00000000000000000000000000000000>:0)
    DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.InitPart[T] (T newPart, System.String contentType, System.String id) (at <00000000000000000000000000000000>:0)
    DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.InitPart[T] (T newPart, System.String contentType) (at <00000000000000000000000000000000>:0)
    DocumentFormat.OpenXml.Packaging.WordprocessingDocument.AddMainDocumentPart () (at <00000000000000000000000000000000>:0)
    DefaultNamespace.ResumeBuilder.Generate () (at <00000000000000000000000000000000>:0)
    UnityEngine.Events.UnityEvent.Invoke () (at <00000000000000000000000000000000>:0)
    UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at <00000000000000000000000000000000>:0)
    UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, System.Boolean pressed, System.Boolean released) (at <00000000000000000000000000000000>:0)
    UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () (at <00000000000000000000000000000000>:0)
    UnityEngine.EventSystems.StandaloneInputModule.Process () (at <00000000000000000000000000000000>:0)
     
  21. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    I got response from Unity that the bug is fixed in 2020 and will be backported to 2019.3 but they don't know when
     
    nakkalokesh99 likes this.
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    It's on its way. I fixed it a few weeks ago and it's now in review phase.
     
    nakkalokesh99 and Kamyker like this.
  23. shiena

    shiena

    Joined:
    May 19, 2017
    Posts:
    44
  24. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    We actually found that the fix breaks the burst compiler. It will take a bit longer for it to get into 2019.3.
     
    not_a_valid_username likes this.
  25. rchallenger

    rchallenger

    Joined:
    Oct 15, 2014
    Posts:
    2
    Hello, I believe I experience issue tightly related to this thread.

    I'm developing a VR project for Standalone. I use the a number of third-party Dll plugins for Windows x64 platform. In Editor mode everything works great, but the built project does not work as it is expected. After I launch compiled app, it says that not all modules in third-party plugins are available. Also VR is launched in some default mode, when camera is configured in stereo mode. After I move files from [_data/Plugins] to [_data/Plugins/x86_64] (where my third-party libraries are stored) VR works good and I can see the scene through my VR kit. To make my third-party plugin see all its modules I have to copy my third-party plugins, located in [_data/Managed] to the location of my native Dll files [_data/Plugins/x86_64]. After these manipulations built project works like it used to in Editor mode.

    Is there any solution for that except moving/copy-pasting workaround?

    All third-party plugins are tightly dependent on each other.
    From my code I use DllImport for native c++ Dll and reference another plugin from my own Dll (using types and classes declared inside).

    Unity 2019.3.0f6
     
    Last edited: Feb 18, 2020
  26. averysmarttardigrade

    averysmarttardigrade

    Joined:
    Sep 18, 2019
    Posts:
    11
    @Tautvydas-Zilys I am having the same issue, with ArrayFire. I built the project in development mode, and it is having trouble with it. Would you mind walking me through the steps to fix it? I am using Unity 2018.4.9f1. I can provide more information if needed. Thanks for all your help! I also am inexperienced with importing dlls to Unity, and I got them via Nuget in VS. The NN (what I am using array fire for) works in editor, but not stand alone.
     
  27. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I'm not really sure which issue you're talking about. This thread talks about 10 different ones. Could you go into more details?
     
  28. averysmarttardigrade

    averysmarttardigrade

    Joined:
    Sep 18, 2019
    Posts:
    11
    First of all, thanks for a quick response. To sum up the issue-I have an NN in creatures, and creatures are forced to eat the first couple food they encounter. However, this isn't happening in the built stand alone, but in the editor. When I built the project as a development build I get the error- DllNotFoundException: af. The af is referring to the ArrayFire dll I was using, and ArrayFire is an important part of the NN. Since the Dll isn't working, neither will the NN.
    Thanks!
     
  29. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you post the exact error message you're getting? Does it work in the editor? Does it fail to load in 32-bit or 64-bit player, or both?
     
  30. averysmarttardigrade

    averysmarttardigrade

    Joined:
    Sep 18, 2019
    Posts:
    11
    DllNotFoundException: af, is the exact error. It does work in the editor. I'm not sure how to run it in 64 bit, but it doesn't work in 32 bit, and probably not 64 but. I am relatively new to unity GUI. I can script in C# with the Unity functions, but unfamiliar with project building, ect.
    Thanks!
     
  31. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Does "af.dll" exist anywhere within your project? If it does, what settings does it have set on it?

    To build a 64-bit build, select "x86_64" architecture instead of "x86" when building for Windows.
     
  32. averysmarttardigrade

    averysmarttardigrade

    Joined:
    Sep 18, 2019
    Posts:
    11
    FYI, I am on a mac. Its not the best with C#, but it works. The af.dll does exist in my project, with no specific settings, just a dll. I am pretty inexperienced with dlls, but I am pretty sure it is just a file.
     
  33. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Well, it would have been great to know about this up front - this is a Windows forum :p. Anyway, are you on 2019.3 by any chance? There is a known issue with in Mac Standalone player but I believe it's possible to work around.
     
  34. averysmarttardigrade

    averysmarttardigrade

    Joined:
    Sep 18, 2019
    Posts:
    11
    Unfortunately I am on 2018.4.9f1. :(
     
  35. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Then it should not be broken. Since you're on Mac, you should be looking for "af.bundle". Does that exist in your project? If so, could you click on it and screenshot the inspector?
     
  36. averysmarttardigrade

    averysmarttardigrade

    Joined:
    Sep 18, 2019
    Posts:
    11
    I do not recall downloading af.bundle, and I don't think it is in my project. I looked all over, and didn't see it, and it wasn't with the other dlls.

    Thanks!
     
  37. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    So the exception seems legitimate: you af.dll is Windows version of the plugin but you have no Mac equivalent.
     
  38. averysmarttardigrade

    averysmarttardigrade

    Joined:
    Sep 18, 2019
    Posts:
    11
    Oh, ok thanks. But wouldn't that mean that it wouldn't work in the editor? Plus, I think I downloaded the mac version. I could try re-downloading, but it is a pain to get dlls to Unity.
    https://arrayfire.com/download/

    Thanks!
     
  39. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    To be honest, I've no idea why this error is not showing up in the editor. Perhaps you're not calling into said code in the editor? If you are, are you sure there isn't a native binary for macOS in your project?
     
  40. averysmarttardigrade

    averysmarttardigrade

    Joined:
    Sep 18, 2019
    Posts:
    11
    I'll surf the web a little to try and find out whats going on.
    Thanks!
     
  41. dershver_unity

    dershver_unity

    Joined:
    Jun 2, 2020
    Posts:
    8
    I just downloaded 2019.4.0f1 and I am still getting a DLL Not found exception.
    Was this bug fixed in that release ?
     
  42. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Yes it was fixed a while back. You're likely running a different issue. What DLL can't it found and did you verify that the DLL is there?
     
  43. samisuleman1

    samisuleman1

    Joined:
    Jun 13, 2019
    Posts:
    2
    These settings does not put my .dll files to plugin folder and creates a x86_64 folder. I am using unity 2019.3.0 f6.
    What can be the problem?
     
  44. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    Update to unity 2019.4
     
  45. dershver_unity

    dershver_unity

    Joined:
    Jun 2, 2020
    Posts:
    8
    I found the problem. One of lib's included in these DLL had some code that reference an MFC lib.
    Even though, I was not using this function it gave me the DLL not found exception. I removed this lib and created
    a new lib that had no MFC references and everything worked.
     
  46. Pan_Migo

    Pan_Migo

    Joined:
    Oct 3, 2016
    Posts:
    4
    Hello everyone,

    The same issue more or less here. I am using a dll and it plays fine when in the editor, but is not loaded when I build the game. The strange thing however is that it plays also fine when I make a development build with script debugging enabled. How should I approach the issue?
     
  47. s-elliot-perez

    s-elliot-perez

    Joined:
    Mar 4, 2016
    Posts:
    22
    EDIT: OK, I found the reason I had this problem was that my machine and the plugin are x86_x64, but the build was set to be x86. This still runs on a 64-bit machine, but since the dll wasn't made for that, it couldn't be loaded.
     
    Last edited: Oct 23, 2020
    Shiiv likes this.
  48. Jop517

    Jop517

    Joined:
    Dec 14, 2020
    Posts:
    1
    the program can't start the file api-ms-win-ntuser-sysparams-l1-1-0.dll is missing. what now how to get rid of this error on my PC. I found the same file on this website <SNIP> and now I'm a bit confused about what to do, download the file or just reinstall the program once again, already did it once.
     
    Last edited: Dec 15, 2020
  49. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Don't download system DLL files from third party websites (and please don't post links to them here). They are very likely to be malicious.

    What OS are you on? And when are you getting this error?
     
    tteneder likes this.
  50. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you show the DLL plugin importer settings?