Antonino
Antonino

Reputation: 3258

Custom dll integration into a HoloLens project

I have a custom library with source code that successfully compiles and produces the .dll file.

Question: what's the best approach to include this dll in a HoloLens project considering the following errors?

My approach

The project.json file of the standalone library is the following:

{
  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
    "Newtonsoft.Json": "9.0.1"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

Or I have also the opportunity to add it as a NuGet package depending on:
- Microsoft.NETCore.UniversalWindowsPlatform (>= 5.2.2)
- Newtonsoft.Json (>= 9.0.1)
- Microsoft.EntityFrameworkCore.Tools (>= 1.0.0-preview2-final)
- Microsoft.EntityFrameworkCore.Sqlite (>= 1.0.1)

Then I need to include this library in another VS2015 solution produced by Unity for Hololens. The solution automatically built by Unity consists of 3 projects: 1) Assembly-CSharp containing a HoloToolkit folder, 2) Assembly-CSharp firstpass and 3) Origami

screenshot

I took a script from HoloToolkit for Unity folder and I applied it on a GameObject. When an event is triggered - and it happens successfully - I want to call some functions provided by this custom library to process it from the same script, say GazeManager.cs. The project.json of the project 1) is the following

{
  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

I tried in 2 ways:

The command ""C:\Users\Antonino\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Unity\Tools\AssemblyConverter.exe" -platform=uap -lock="C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\project.lock.json" -bits=32 -configuration=Debug -removeDebuggableAttribute=False -path="." -path="..\Players\UAP\x86\Debug" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\Assembly-CSharp.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\Assembly-CSharp-firstpass.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\UnityEngine.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\UnityEngine.UI.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\UnityEngine.HoloLens.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\UnityEngine.Networking.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\UnityEngine.VR.dll"" exited with code 1.

and in this case I got the following errors

Payload contains two or more files with the same destination path 'System.Net.Sockets.dll'. Source files: C:\Users\Antonino.nuget\packages\runtime.win.System.Net.Sockets\4.1.0\runtimes\win\lib\netcore50\System.Net.Sockets.dllC:\Users\Antonino.nuget\packages\System.Net.Sockets\4.0.0\lib\netcore50\System.Net.Sockets.dll Payload contains two or more files with the same destination path 'System.Diagnostics.Tools.dll'. Source files: C:\Users\Antonino.nuget\packages\runtime.any.System.Diagnostics.Tools\4.0.1\lib\netcore50\System.Diagnostics.Tools.dllC:\Users\Antonino.nuget\packages\System.Diagnostics.Tools\4.0.0\lib\netcore50\System.Diagnostics.Tools.dll Payload contains two or more files with the same destination path 'System.Threading.Timer.dll'. Source files: C:\Users\Antonino.nuget\packages\runtime.any.System.Threading.Timer\4.0.1\lib\netcore50\System.Threading.Timer.dllC:\Users\Antonino.nuget\packages\System.Threading.Timer\4.0.0\lib\netcore50\System.Threading.Timer.dll Version conflict detected for System.Collections. Origami (>= 1.0.0) -> Assembly-CSharp (>= 1.0.0) -> my.hololens.library (>= version) -> Microsoft.EntityFrameworkCore.Tools (>= 1.0.0-preview2-final) -> Microsoft.EntityFrameworkCore.Design (>= 1.0.0-preview2-final) -> Microsoft.EntityFrameworkCore.Design.Core (>= 1.0.0-preview2-final) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 1.0.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 1.0.0) -> System.Reflection.TypeExtensions (>= 4.1.0) -> System.Linq (>= 4.1.0) -> System.Collections (>= 4.0.11) Origami (>= 1.0.0) -> Microsoft.NETCore.UniversalWindowsPlatform (>= 5.0.0) -> Microsoft.NETCore.Runtime (>= 1.0.0) -> Microsoft.NETCore.Runtime.CoreCLR-arm (>= 1.0.0) -> System.Collections (= 4.0.10). One or more packages are incompatible with UAP,Version=v10.0 (win10-x86-aot). One or more packages are incompatible with UAP,Version=v10.0 (win10-arm-aot). System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86-aot. System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot. System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86-aot. System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot. One or more packages are incompatible with UAP,Version=v10.0 (win10-x64-aot). Version conflict detected for System.Collections. Assembly-CSharp (>= 1.0.0) -> my.hololens.library (>= version) -> Microsoft.EntityFrameworkCore.Tools (>= 1.0.0-preview2-final) -> Microsoft.EntityFrameworkCore.Design (>= 1.0.0-preview2-final) -> Microsoft.EntityFrameworkCore.Design.Core (>= 1.0.0-preview2-final) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 1.0.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 1.0.0) -> System.Reflection.TypeExtensions (>= 4.1.0) -> System.Linq (>= 4.1.0) -> System.Collections (>= 4.0.11) Assembly-CSharp (>= 1.0.0) -> Microsoft.NETCore.UniversalWindowsPlatform (>= 5.0.0) -> Microsoft.NETCore.Runtime (>= 1.0.0) -> Microsoft.NETCore.Runtime.CoreCLR-arm (>= 1.0.0) -> System.Collections (= 4.0.10). One or more packages are incompatible with UAP,Version=v10.0 (win10-x64-aot). One or more packages are incompatible with UAP,Version=v10.0 (win10-x86-aot). System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm-aot. One or more packages are incompatible with UAP,Version=v10.0 (win10-arm-aot). System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm-aot.

I'm puzzled on what to go on. Somebody said to produce a portable library, and I also tried to study here the relationship among NETFramework, NETCore and NETStandard but it seems more complex than expected.

Upvotes: 0

Views: 1984

Answers (2)

Dheeraj Kumar
Dheeraj Kumar

Reputation: 108

You need to create a UWP Library project and port your code to this project and compile , remove errors Place compiled dll in assets folder Update Inspector properties as shown below

in this image

Now you can access this dll in your unity scripts under #if !UNITY_EDITOR block

Upvotes: 2

Cameron Vetter
Cameron Vetter

Reputation: 747

Unity 3d does not support integration of libraries that use the .Net Core framework. Try creating your library as a .Net Framework 3.5 Library and drop it in the Assets/Plugins folder of your Unity project.

Upvotes: 2

Related Questions