Quantcast
Channel: Questions in topic: "dll"
Viewing all articles
Browse latest Browse all 706

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

$
0
0
I am re-familiarising myself with Unity after roughly 2 years working in non-Unity projects, so there may be new features in the newer versions of Unity. 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 assemblies[link][1]. 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 [1]: (https://answers.unity.com/questions/1216201/import-mixed-assembly-managed-ccli-dll-plugin.html)

Viewing all articles
Browse latest Browse all 706

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>