Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

[SOLVED] How to install Infer.NET to Unity 2018.3

Discussion in 'Formats & External Tools' started by Matti-Jokipii, May 7, 2019.

  1. Matti-Jokipii


    Apr 24, 2015
    I have a fresh Unity project and following the instructions in Using .NET 4.x in Unity, i've downloaded Microsoft.ML.Probabilistic.Compiler NuGet package from the gallery and copied the DLL to Assets/Plugins. After this Unity outputs an error message

    Assembly 'Assets/Plugins/Microsoft.ML.Probabilistic.Compiler.dll' will not be loaded due to errors: Unable to resolve reference 'Microsoft.ML.Probabilistic'. Is the assembly missing or incompatible with the current platform?

    I downloaded and copied the missing DLL and every following missing DLL dependency
    • Microsoft.ML.Probabilistic.dll
    • System.CodeDom.dll
    • Microsoft.CodeAnalysis.CSharp.dll
    • Microsoft.CodeAnalysis.dll
    • System.Collections.Immutable.dll
    • System.Reflection.Metadata.dll
    Unity showed no more errors after adding the System.Reflection.Metadata.dll.

    When i add
    Code (CSharp):
    1. using Microsoft.ML.Probabilistic;
    2. using Microsoft.ML.Probabilistic.Compiler;
    to a script, the project builds fine in both Unity and Visual Studio Community, but when i attempt to use the libraries
    Code (CSharp):
    1. using UnityEngine;
    2. using Microsoft.ML.Probabilistic;
    3. using Microsoft.ML.Probabilistic.Compiler;
    5. public class Main : MonoBehaviour {
    6.     void Start () {
    7.         Variable<bool> firstCoin = Variable.Bernoulli (0.5);
    8.     }
    9. }
    both Unity and Visual Studio fail with

    Assets/Scripts/Main.cs(7,3): error CS0246: The type or namespace name 'Variable<>' could not be found (are you missing a using directive or an assembly reference?)


    Assets/Scripts/Main.cs(7,30): error CS0103: The name 'Variable' does not exist in the current context​

    to Assets/mcs.rsp file generates an error

    Microsoft (R) Visual C# Compiler version (9d34608e)
    Copyright (C) Microsoft Corporation. All rights reserved.

    error CS0006: Metadata file 'Microsoft.ML.Probabilistic.Compiler.dll' could not be found

    The project configuration is
    • Unity 2018.3.10f1
    • Visual Studio for Mac Community
    • Build Settings/Platform: iOS
    • Player Settings/Scripting Runtime Version: .NET 4.x Equivalent
    it makes no difference whether i set
    • Player Settings/Api Compatibility Level: .NET 4.x
    • Player Settings/Api Compatibility Level: .NET Standard 2.0
    Other settings are left to their defaults.

    I haven't added the DLLs to the vs-project in Visual Studio as the guide says

    Visual Studio regenerates .csproj and .sln files for Unity projects each time they're opened. As a result, you cannot add assembly references directly in Visual Studio because they'll be lost upon reopening the project. Instead, a special text file named mcs.rsp must be used:

    Create a new text file named mcs.rsp in your Unity project's root Assets directory.

    On the first line in the empty text file, enter: -r:System.Net.Http.dll and then save the file. You can replace "System.Net.Http.dll" with any included assembly that might be missing a reference.

    Restart the Unity editor.

    This is a cross post with my Stack Overflow question that i've received no answers

    I would love to use this library and would appreciate any help you can offer.
  2. Matti-Jokipii


    Apr 24, 2015
    Hmm... no replies. Help me out if you know a better subforum for this kind of question. Not exactly sure this is a question for External Tools.
  3. Matti-Jokipii


    Apr 24, 2015
    For anyone interested, the above installation actually works, i was just missing the fact that the Variable<T> is in the Microsoft.ML.Probabilistic.Models namespace. FYI: The library doesn't support AOT so it won't work on iOS.