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.

DLL cannot be loaded, but it is right there next to the executable.

Discussion in 'Windows' started by Zergling103, Jul 8, 2022.

  1. Zergling103

    Zergling103

    Joined:
    Aug 16, 2011
    Posts:
    373
    When I try to run our game on some computers, the code in the native DLL executes without a problem. However on others, it simply throws an exception and refuses to run.

    Computers that can successfully run the native DLL have Visual Studio Community 2022 installed.

    Code (CSharp):
    1. DllNotFoundException: Unable to load DLL 'Native.dll'. Tried the load the following dynamic libraries: Unable to load dynamic library 'Native.dll' because of 'Failed to open the requested dynamic library (0x06000000) - The specified module could not be found.  (WinError:0000007e)
    Strangely, an earlier build of the game doesn't have this problem. It is likely I was using Visual Studio Community 2015 at that time to compile the DLL.

    How do I fix this? Just switch back to VS 2015?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,009
    Illusion-Walk likes this.
  3. Zergling103

    Zergling103

    Joined:
    Aug 16, 2011
    Posts:
    373
    When I rebuilt the DLL in Visual Studio 2015, the DLL worked flawlessly on other machines.

    The funny thing is, it is obvious these "dependencies" are just filler crap tacked on by visual studio. They aren't used by the source code, and can be excluded by compiling using an older version of VS. The code in the DLL is just a series of math instructions.

    Still, it would be good to know what VS2022 is doing differently.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,009
    You likely configured the project to link CRT dynamically instead of statically would be my guess. But looking at it through "Dependencies" is the only way to know for sure.