Problem importing a mixed-mode (C++/CLI) library

I am re-familiarising myself with Unity after roughly 2 years working in non-Unity projects, so there may be new features that I am not familiar with. I am developing a topological software library called Topologic (https://topologic.app/) and would like to make it work in Unity. This library contains 2 layers: native layer (C++) and a managed layer (written in C++/CLI). My problem is that I cannot simply load the managed DLL. After loading the DLL (adding it as a reference in Visual Studio), the classes inside it, Unity fails to run the code.

What I wrote in the Unity code (.cs) is as follows.

Topologic.Vertex vertex = Topologic.Vertex.ByCoordinates(0, 0, 0);

This is fine in Visual Studio, but Unity gives me the following messages.

Assets\TestUnity.cs(14,9): error CS0246: The type or namespace name 'Topologic' could not be found (are you missing a using directive or an assembly reference?)
Assets\TestUnity.cs(14,35): error CS0103: The name 'Topologic' does not exist in the current context

I have been reading existing posts and (please correct me if I am wrong) there seems an incompatibility issue with C++/CLI. It has been suggested that this happens because Unity uses Mono .NET which does not support mixed-mode assemblies1. This post comes from 2016, so I am wondering if if this is still the case?

Another question is, is there any solution to circumnavigate this problem? I am trying to find methods simpler than using P/Invoke. What I have tried are:

  1. Create a purely managed DLL (C#) that inherits classes in the C++/CLI DLL. Produces the above error messages.
  2. Compile the C++/CLI DLL with /pure:clr (as suggested in the link above), but this produces tons of error messages in Visual Studio.

Many thanks,

Nicholas

I don’t think Unity Supports C++.

You should copy your DLL into your plugins folder in Unity. Adding references manually to the C# project in Visual Studio has no effect since Unity does not use that project at all. Unity compiles the scripts itself by running the compiler directly. Any references has to be setup directly in Unity. The VS project only exists so IDEs like visual studio can work with it. If you have the dll inside your plugins folder (inside your assets folder), Unity will add the references automatically.