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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

referencing .NET 4 targeted, native code wrapper assembly in Unity beta (Google.OrTools)

Discussion in 'Scripting' started by sershe, Oct 30, 2016.

  1. sershe

    sershe

    Joined:
    Sep 9, 2016
    Posts:
    15
    I am trying to use a well known Google.OrTools (https://developers.google.com/optimization/) package in Unity for C#. This contains C# wrappers for a number of graph algos (and other things) implemented in C++, with PInvoke; it requires Mono 4.2.
    I tried the recent beta build that allows one to target .NET 4.6 and switched the project to 4.6. When I import Google.Protobuf.dll from the same package, everything is good (and the asset properties say that it targets .NET 4-something).
    However, Google.OrTools gets imported as "native" DLL.
    Is there some fundamental problem with Unity and PInvoke, or is unity just "confused"? Can I force it to consider it a managed DLL somehow? I don't care about any compat at this point.
    Also, if I add it to the VS project manually, I cannot build in Unity (reference is not added), but I can build in VS - with warnings that the DLL targets .NET 4 and the project targets .NET 2. It is surprising that 2.0 is the target in VS when 4.6 is chosen in Mono project properties... could this be related, or is it just an orthogonal problem with the .NET 4.6 beta?
     
  2. Weaver

    Weaver

    Joined:
    Jul 2, 2013
    Posts:
    18
    Hello, did you ever figure something out for this? I'm also trying to import Google.OrTools but it thinks it's a native plugin for some reason.