Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Problems with Kinect 2 dll and .NET 4.6 profile

Discussion in 'Experimental Scripting Previews' started by npatch, Jul 15, 2017.

  1. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    Hi,
    I tried to use the experimental 4.6 profile and load up the same dll that Kinect v2 apps use instead of the Microsoft Unity package for the Mono 2.0 set.

    I'm getting this problem.
    https://drive.google.com/file/d/0B1GIJ_Q90WIHUkI2ak8wUnVzT0U/view?usp=sharing

    I tried adding it as a Reference (though it's listed under the Extensions list). Unity couldn't resolve it. And this happened when I copied over the dll.

    Any ideas what it means?
     
  2. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    I just saw another thread about this and seems like a bug report was filed out with the response:
    "Try including the Non-reference assemblies for Microsoft.Kinect in your project "
    Well if that means Microsoft.Kinect.dll then it still doesn't compile.

    UPDATE: Looked at all dlls present in the machine but none works. Even used an assembly present in GAC. Is it possible for a library to expose only a wrapper to a native library and be compiled as a Reference Assembly?
     
    Last edited: Jul 15, 2017
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Are you trying this on Windows or macOS?
     
  4. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    Windows 10 x64. I saw a video on Sunday where people from the Kinect team from Microsoft(K4W) where saying they were using the Kinect Common Bridge project for Unity as well as other frameworks which is basically a common C API for easy integration with anything.

    I could be very wrong with this and I'm not sure whether what I'm gonna say even makes sense for Reference Assemblies,but I suspect the C# dll is a wrapper over the C API with some extra bookkeeping the same way the Unity package's C# code is. But it's still referencing the native dll.

    Thanks for they reply btw!
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Do you mind submitting a bug report? I think this should work on Windows 10, but a bug report will help us track down the specific issue more quickly.
     
  6. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    There's already one by another user which I found out after reading another thread:https://fogbugz.unity3d.com/default.asp?889222_hkf7n7ch1spi7sof

    Problem is I don't know whether or not there are any non-reference assemblies for Kinect.
    Are you gonna use a modified Mono this time as well? Is this possible to revert in the newer Mono version?

    PS: I can submit a new bug report with a sample-project if you like, but I don't think there's gonna be a different answer than the previous one. Sorry for the duplicate thread by the way.
     
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I'm not familiar with the Kinect assemblies, but there must be some non-reference assemblies that actually have the code which is needed to run (reference assemblies are only used for compilation).

    I agree that a new bug report won't probably provide any additional information though.

    Generally, we're still working on support for reference assemblies and .Net standard in Unity. Once that is ready I think things like this will be much simpler.
     
    migupta likes this.
  8. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    Hmm...I looked everywhere for .NET assemblies though. And I tried to import the GAC one in the project. Can't imagine there being an assembly in the GAC which is not correct. I also tried any other assembly I could find that looked like .NET from a file explorer search. None worked. I think the assembly from the GAC was down right ignored and another assembly from Program Files removed any compilation errors but failed to load on Runtime.

    I could try providing a sample project with both of those, in case you figure out something about the assembly that was ignored. Or maybe if they're linked somehow.
    Do Reference Assemblies need another assembly with the same name but in a different location to properly compile and execute?
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Yes, a reference assembly needs something else. It is only used to define an API at compile time, and it contains no executable code. So there should be another assembly somewhere that defines the code which actually runs.
     
    migupta likes this.
  10. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    I created a new project using the latest 2017.2 beta. Inside the project there's a README which has info about the assemblies in the Plugins folder. I found both the reference and the referenced assembly but it's a bit weird. The referenced assembly does not hold on its own nor is it enough to use the API.

    If I remove the reference assembly and leave the native one, I can then go to VS and add the reference manually because Unity ignores it for some reason. VS understands the reference and all errors go away and can build correctly, but Unity doesn't want to remove the errors.


    This should give more insight.
    Here's a link to the project: https://drive.google.com/open?id=0B1GIJ_Q90WIHSGFLMEJ2OUtBdVE
     
    Last edited: Jul 18, 2017
  11. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    @JoshPeterson Should I file a bug report with the project or does it serve as is?
     
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Actually, I think that we can correct this without a bug report. Unity does not read the .csproj file that Visual Studio uses, so adding a reference there won't cause that reference to be used when Unity compiles the C# files.

    To add a reference to an assembly in Unity, you should create a file named mcs.rsp in the Assets folder. This is a text file which has additional arguments for the C# compiler. In this case, you can use the -r argument to pass the path to an additional assembly to reference.
     
  13. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    Ok so I tried both
    and
    meaning both the reference and the native assemblies.

    But I get:
    Code (CSharp):
    1.  
    2. TypeLoadException: Could not load type of field 'KinectTestScript:m_pKinectSensor' (0) due to: Could not load file or assembly 'Microsoft.Kinect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. assembly:Microsoft.Kinect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 type:<unknown type> member:<none>
    3. System.RuntimeType.GetFields_internal (System.String name, System.Reflection.BindingFlags bindingAttr, System.RuntimeType reflectedType) (at <aa1756d827e14afe8f4b9355672b2ab4>:0)
    4. System.RuntimeType.GetFieldCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Boolean allowPrefixLookup) (at <aa1756d827e14afe8f4b9355672b2ab4>:0)
    5. System.RuntimeType.GetFields (System.Reflection.BindingFlags bindingAttr) (at <aa1756d827e14afe8f4b9355672b2ab4>:0)
    6. UnityEditor.MonoScriptImporterInspector.ShowFieldInfo (System.Type type, UnityEditor.MonoImporter importer, System.Collections.Generic.List`1[T] names, System.Collections.Generic.List`1[T] objects, System.Boolean& didModify) (at C:/buildslave/unity/build/Editor/Mono/Inspector/MonoScriptInspector.cs:74)
    7. UnityEditor.MonoScriptImporterInspector.OnInspectorGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/MonoScriptInspector.cs:125)
    8. UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, System.Int32 editorIndex, System.Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1240)
    9. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    10.  
    11.  




    Also in case you didn't open the project,I discovered these last time:
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I've not taken a look at the project yet. At this point I think it is worth submitting a bug report though, so that we can track this issue. I'm not sure why this does not work.
     
  15. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Thanks! We will investigate this.
     
  17. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    Any news about this?
     
  18. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Unfortunately no, we have not had a chance to investigate this yet.
     
  19. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    Ok thanks.
     
  20. overthrowrobotics

    overthrowrobotics

    Joined:
    Jun 19, 2015
    Posts:
    47
    It's been a year since the last update on this. Anything new?
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Yes, the problem in this bug report was that a reference assembly was being used. Reference assemblies are used on for C# compilation to define an interface. They don't have any code to execute. The original submitter needed to use an actual assembly with code in this case.

    I'm not sure if you are facing the same issue though.
     
  22. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    I remember finding out that the native assembly was C++/CLI. Tried that alone in the Plugins folder but it also didn't work.
    Mentioned that in #13 post.
     
  23. crawfis

    crawfis

    Joined:
    Jan 30, 2014
    Posts:
    114
    Was this ever fixed. We would like to upgrade our Unity projects that use the Kinect, but are stuck at .NET 3.5
     
  24. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I don't believe that there was anything to fix on the Unity side. Since you're still experiencing this though, maybe it is a different issue. Can you submit a bug report?