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. Dismiss Notice

DllNotFoundException only on 1 computer?

Discussion in 'Editor & General Support' started by Stankiem, Sep 14, 2014.

  1. Stankiem

    Stankiem

    Joined:
    Dec 4, 2013
    Posts:
    115
    I develop on two different computers with free unity. On one I can run my application fine, on the other, I receive a "DllNotFoundException" error. I have the DLL in the same spot on both machines (in root project folder and also in assets folder) How can I fix this? =(

    The DLL is the RakNet DLL compiled for c# via SWIG.

    Full errors:
    DllNotFoundException: RakNet
    RakNet.RakNetPINVOKE+SWIGExceptionHelper..cctor () (at Assets/RakNet/RakNetPINVOKE.cs:106)
    Rethrow as TypeInitializationException: An exception was thrown by the type initializer for SWIGExceptionHelper
    RakNet.RakNetPINVOKE..cctor ()
    Rethrow as TypeInitializationException: An exception was thrown by the type initializer for RakNet.RakNetPINVOKE
    RakNet.BitStream..ctor ()
    Networking..ctor ()

    NullReferenceException: Object reference not set to an instance of an object
    HandlePacket_LoginScreen.Update () (at Assets/HandlePacket_LoginScreen.cs:126)
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    This happens when it either cannot find the DLL you're P/Invoking into, or any of its dependencies. Since you say you put it to same location on both PCs, I can bet you're getting the second issue. You can use application called "Dependency Walker" on the target PC to see what DLLs you're missing.
     
    Stankiem likes this.
  3. Stankiem

    Stankiem

    Joined:
    Dec 4, 2013
    Posts:
    115
    Thank you for the reply. Does anyone have a good tutorial on how to use Dependency Walker effectively? I just ran it on the PC that is running the game fine, and it comes back with tons of errors and red. Would be nice to know how to sort through all the useless information to get to the stuff I care about. =)
     
  4. Stankiem

    Stankiem

    Joined:
    Dec 4, 2013
    Posts:
    115
    bump, hopefully someone has knowledge of a good tutorial / guide to using dependency walker?
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    It's pretty straightforward to use.

    First of all, you need to download the version of dependency walker that matches the bitness of your game. If you exported 32-bit player from Unity, you'll need 32-bit version of dependency walker. If you exported 64-bit player, you'll need 64-bit dependency walker.

    Once you have that, drag your game executable to dependency walker window. It should look something like this:

    http://i.imgur.com/XZQr8hL.png

    On the top left side, you can see the dependency tree. Your game executable depends on the DLLs on the first tier, while those DLLs depend on the DLLs in the second tier, which depend on the third tier, and so on.

    You can see the sum of all dependencies in the bottom window. As you can see, there are question marks next to some DLL names, for example: "PHONEAPPMODELHOST.dll", "PHONEAUDIOSES.dll". If I tried to P/invoke into this DLL, I would get DllNotFoundException, because these DLLs do not exist on my PC.
     
    Stankiem and Graham-Dunnett like this.
  6. Stankiem

    Stankiem

    Joined:
    Dec 4, 2013
    Posts:
    115
    ^that little tip was a big help firstly.

    These API-MS-WIN-....... files which appear to be missing all over the place. It appears I should just ignore these for the most part? They are appearing on the PC with issues and also on the one without issues.

    There is no mention of RakNet.dll inside of Dependency Walker until I do a profile, but you don't suggest profiling in your short writeup. I assume performing a profile is necessary to get the rull dependency details of an application?

    Thanks again!
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    API-MS-WIN-* are mostly protected OS dlls which dependency walker cannot see due to lack of rights - it's very unlikely you're missing those DLLs. If you're invoking the DLL through P/Invoke, you will not see it in Dependency Walker. You should instead drop that DLL into dependency walker to see what dependencies the DLL itself is missing.
     
    Stankiem likes this.
  8. Stankiem

    Stankiem

    Joined:
    Dec 4, 2013
    Posts:
    115
    Thanks so much for your help!!!! Couldn't have solved this probably within the next couple months without it. So it was looking for MSVC++ redistributable debug version which led me to the fact that I compiled the DLL in debug mode. After a few hours of searching how to compile RakNet via SWIG into a release DLL, I got the new DLL to compile and replaced the old one. It worked like magic! Thanks again support, can't wait till I can afford Unity Pro.