Method contains unsupported native code


I’m currently working on my master thesis and am trying to make everything work in Unity3D. I’m trying to visualize a delaunay tetrahedralization using tetgen software. The point is that tetgen is written in C++. So far, after a lot of effort, I have been able to compile the tetgen source code into a .dll file for use with c# using a c++/cli wrapper. This works fine, that is, untill i try it Unity…

I’m getting the following error: “Method contains unsupported native code”. Now, as far as my google-fu goes, this is because the dll is unsafe and recompiling the dll using /clr:safe should fix the problem. That, however, is going to be impossible. So my question is: is it possible to circumvent this problem somehow, or some other way I could go about to solve this problem? I would really like to use Unity, but if I can’t integrate tetgen with it, I’m gonna start to look for alternatives. I have already lost a lot of time trying to solve this. Also, I don’t have Unity pro (too expensive for just a student).

Thanks in advance,


Mono (which unity uses) does not support mixed-mode assemblies.

You can use C++/CLI if you use 100% managed code with the right compiler options.

Instead, you can write a C (or C++ with the right mangling options) DLL and access it via P/Invoke.

Also, plugins are only supported in the Pro version.