Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SamAgten · Dec 04, 2011 at 09:57 PM · dllunsafe

Method contains unsupported native code

Hi,

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,

Sam

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dannyskim · Dec 04, 2011 at 10:14 PM 0
Share

Unfortunately, plugins that you create are only supported in the pro version, which of course you have already found out on your own. This requires the namespace 'using System.Runtime.InteropServices;' and a Dll import call from your C# scripts inside Unity. I don't believe there is any other way, and if there is a way, it would probably eat way too much of your time developing it.

So in short, I think you may be SOL unless you can get a copy of Pro, which in case since you've already created a wrapper, should work fairly seamlessly from that point on. For documentation if you haven't already visited it, point yourself to:

http://unity3d.com/support/documentation/$$anonymous$$anual/Plugins.html

avatar image Eric5h5 · Dec 04, 2011 at 11:22 PM 0
Share

There's a student version of Pro for $99, which doesn't allow commercial usage. Seems like a master's thesis should be fine.

avatar image SamAgten · Dec 04, 2011 at 11:26 PM 0
Share

@dannyskim : Thank you for your clear and structured answer. I have indeed seen that the pro version can handle plugins better than the indie version can. If you are sure that the pro version can handle dll's containing 'unsafe, unmanaged native' code, I'll try lobbying the university for a license come tomorrow ;). Also, the only examples I've seen using the dll import call in C# are with static external methods. Do you know any good examples where actual classes are imported ins$$anonymous$$d?

Thanks again, you've been very helpful,

Sam

avatar image dannyskim · Dec 04, 2011 at 11:44 PM 0
Share

I don't have any examples handy as my work computer isn't with me, but creating JavaV$$anonymous$$'s is a fairly normal practice inside of Android from Unity. I'll see if I can dig something up that is more relevant to your thesis.

avatar image Megamind · Oct 03, 2013 at 07:44 PM 0
Share

Sam did you solve getting TetGen to work with Unity? Can you expand on just how your were able to have been able to compile the TetGen source code into a .dll file for use with c# using a c++/cli wrapper? How about posting it in the asset store?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by sirbrialliance · Feb 27, 2014 at 12:55 AM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SamAgten · Feb 27, 2014 at 08:54 AM 0
Share

Thanks! I already solved the issue a couple of years ago. I got a temporary license and used P/Invoke like you said.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I pass pointers to DLL functions? 0 Answers

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

reduce size of included dlls? 2 Answers

Why is UnityEngine.dll not signed? 0 Answers

how to load Dll into Unity 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges