Search Unity

Can't import the .NET dll of this SDK. Any reason why?

Discussion in 'Scripting' started by Clavus, Jun 6, 2014.

  1. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    Here's a download: https://dl.dropboxusercontent.com/u/11217331/VSDK.zip

    The .NET dll of this SDK is a wrapper for the unmanaged code in the CPP dll. For some reason, Unity doesn't import the .NET dll whatever I try.

    I tried making a Mono DLL of my own that imports the SDK .NET dll, in an effort to forward the functionality, but I just get a TypeLoadException in the class where the SDK is referenced (since, I guess, the SDK dll still has to be loaded by Unity).

    I don't know what's causing this. The SDK .NET dll is build with .NET 2.0, and doesn't seem to have any incompatibilities with Unity's version of Mono. I'd love to hear why it's not working.
     
  2. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Do you use Unity Pro?
     
  3. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    Yes. Plus I can import .NET dlls that I compile myself just fine.
     
  4. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Perhaps some 32 / 64 bit missmatch . I opened the dll with Dependency Walker and it seems that these dll are 64bit (x64). You can't load these dll from a 32bit app like Unity-Editor. You can check if you can publish your app as x64 and see if it runs with the dlls. Otherwise recompile them for x86 or anyCPU.
     
  5. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    dotPeek says the .NET dll is x86 (not x64 or msil). Dependency Walker doesn't show the 64-bit icon when I load in the .NET or CPP dlls. Are you sure?
     
  6. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Yes I looked at the wrong place. Your dll seems to be a x86.
    Perhaps it is some problem with the C++ Runtime. Do you know what compiler was used for the c++ dll. Everthing installed? (Microsoft Visual C++ Redistributable Package)
     
  7. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    No idea what was used for the SDK, it came with the 3rd party software. But the SDK .NET dll itself isn't loaded to begin with, nothing indicating that the CPP dll is doing something strange.
     
  8. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Is the MSVCR90.dll beside your dll?
     
  9. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    Nope, but those should be part of my installed .NET redistributals. Downloaded it separately just in case and placed it next to the other dlls, but no change.
     
  10. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Hmm, strange. Is there some useful information in the Editor Logs?
     
  11. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    Not more interesting stuff than this:

    Internal compiler error at Assets/ViconController.cs(9,10):: exception caught while emitting MethodBuilder [ViconController::Start]
    The following assembly referenced from D:\Data\Workspace\Unity\Projects\ViconVR\Assets\Plugins\x86\UnityViconInterface.dll could not be loaded:

    Assembly: ViconDataStreamSDK_DotNET (assemblyref_index=1)
    Version: 0.0.0.0
    Public Key: (none)

    The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (D:\Data\Workspace\Unity\Projects\ViconVR\Assets\Plugins\x86\).

    Could not load file or assembly 'ViconDataStreamSDK_DotNET, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.​


    The UnityViconInterface.dll is my own .NET dll that references the SDK. And yes, there is a copy of the SDK .NET dll located at "D:\Data\Workspace\Unity\Projects\ViconVR\Assets\Plugins\x86\". Unity just acts like it isn't there for some reason.
     
  12. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Relocate the dll all in the Plugins folder (no subfolder) or could you check how the PInvoke calls [DLLImport(...)] are referenced. I once had an issue with DllImport("myDll.dll")] . I had to rename my myDll.dll to myDll.dll.dll as mono is referencing the dll without the file ending ( If your dlll's name is only myDll.dll you have to reference it like DllImport("myDll")] .
     
  13. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    No change. Since I gave the dlls in my original post, you can just whip up a quick test project to see if you can get anything useful out of it. If anyone can get that dll to load in some way, that'd be enough to know it's at least possible.
     
  14. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
  15. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
  16. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    Yes, I have all the requisites for the Vicon SDK installed. Also wouldn't it result in at least a more obvious error if it were the Visual Studio redistributables that I'd be missing?

    Tried adding a smcs.rsp / gmcs.rsp file to my assets folder containing "-unsafe". Didn't change a thing.
     
  17. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Have no more clues. :(
     
  18. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    Thanks for the effort I guess. Seems I'm doomed to digging into C++ and writing a native library using the CPP SDK.
     
  19. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Perhaps they use some c++/cli and the mono version of unity can't handle it.
     
  20. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    Well, good news. Finally got it to load... by going back one Unity version. The .NET DLL loads in Unity 4.3.4f1.

    Any particular reason why it doesn't work in Unity 4.5? It must be something hidden in these patch notes: http://unity3d.com/unity/whats-new/unity-4.5