Hi,
I have a DLL written in C++. It also contains a .NET API written in C++/CLI, and these are linked together in a single DLL. The C++ code uses some Win32-specific calls, so I'm happy to be restricted to Windows platforms for now.
From any regular C# project in Visual Studio, I can just add it as a reference and use the .NET API to seamlessly interact with the library - no need for P/Invoke, `DllImport` or writing a C API.
However, when I import it as an asset into a Unity project, it's recognized as a native plugin, and I can't use the C# API from any scripts in the project - they all behave as if the DLL doesn't exist. The C++/CLI code is compiled against .Net Framework 4.0, so I've set the Scripting Runtime Version to '.NET 4.x Equivalent', and the Api Compatibility Level to '.NET 4.x'.
I tried working around this by writing a C# library in Visual Studio that references the mixed C++/.Net library, and then importing both this C# library and the mixed library into the Unity project. When I do that the scripts in the Unity project compile, but the entire editor crashes when I press play.
Are mixed assemblies just not supported in Unity? If so, I couldn't find this documented anywhere. If they are, how can I figure out why Unity is treating my mixed assembly DLL as a native plugin rather than a managed plugin?
↧