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 Zhehao Wang · Feb 21, 2014 at 06:07 PM · javadllnotfoundexception

Using Java libraries in Unity C# project through IKVM.net: msvcrt dll-not-found

Hello guys,

I'm trying to access my java libraries in a Unity C# project but Unity keeps throwing dll-not-found errors. I'm on Unity Pro 3.5.7 and Mac OS X 10.8.4.

I'm using IKVM to convert java bytecode into .net dll and putting references to those in my Unity project, like the post here, http://forum.unity3d.com/threads/494...e-inside-Unity.

First, I encountered the problem of MonoPosixHelper.dll not found error, which is stated here, http://forum.unity3d.com/threads/999...lper-not-found. According to Unity's dll map, which can be accessed here on a mac, /Applications/Unity/Unity.app/Contents/Frameworks/Mono/etc/mono/config, I found out that MonoPosixHelper.dll actually means libMonoPosixHelper.dylib, and the problem no longer exists after I made a copy of it into my Unity project folder.

However, another problem appears after this one: DllNotFoundException: msvcrt. According to the same dll map I can see it's actually looking for libc.dylib, so I made a copy of that too, but it doesn't work this time. I tried copying it into my project folder, Assets sub folder, scripts sub folder and /Applications/Unity/Unity.app/Contents/Frameworks/Mono/lib folder but none of those worked.

My java library runs well with a standalone Xamarin Studio C# project so I believe it's something weird Unity did with its Mono library.

Does anyone have the same problem or has any ideas on where Unity actually looks for native dlls? (I think libMonoHelper.dylib is native too because it appeared in the library folder of Unity app's content folder, and that makes me wonder why Unity does not recognize that library in the first place)

Here is a copy of my error message.


DllNotFoundException: msvcrt
Mono.Unix.Native.Syscall.CopyUtsname (Mono.Unix.Native.Utsname& to, Mono.Unix.Native._Utsname& from)
Mono.Unix.Native.Syscall.uname (Mono.Unix.Native.Utsname& buf)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters)
ikvm.internal.MonoUtils.unameProperty (System.String )
ikvm.internal.Util..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for ikvm.internal.Util
java.lang.VMSystemProperties.getLibraryPath ()
java.lang.VMSystemProperties.initCommonProperties (java.util.Properties )
java.lang.VMSystemProperties.initProperties (java.util.Properties )
java.lang.Props..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for java.lang.Props
java.lang.System.lineSeparator ()
sun.misc.VM..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for sun.misc.VM
java.nio.Bits..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for java.nio.Bits
java.nio.ByteBuffer..ctor (Int32 , Int32 , Int32 , Int32 , System.Byte[] , Int32 )
java.nio.HeapByteBuffer..ctor (Int32 , Int32 )
java.nio.ByteBuffer.allocate (Int32 capacity)
net.named_data.jndn.util.Blob..ctor (System.Int32[] value)
TestEncodeDecodeInterest.Test () (at Assets/Scripts/init.cs:81)
init.Start () (at Assets/Scripts/init.cs:128)

========================================

Comment
Add comment
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

2 Replies

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

Answer by Zhehao Wang · Feb 24, 2014 at 10:45 PM

Okay, for those who may be trying the same thing: Problem's fixed for OSX 10.8.4 and Unity 4.3.4.

After spending days trying everything I know regarding DllNotFound exceptions, we tried a newer version of Unity(4.3.4) and it simply worked. Whatever Unity's done with itself, it solved this problem at least. (One noticeable thing: Unity 4.3.4 and 3.5.7 are both using mono 2.6.5, which means it's not an upgrade of mono that fixed the problem) (There were errors, java.util.Date and GregorianCalendar at first)

Further note for users looking to use Java code. IKVM dlls references System.Drawing, which is not allowed by Unity. So IKVM runs in Unity, but Unity won't allow you to build. There are methods discussed in other threads to get around this restriction, but it seems that those methods can cause Unity/MonoDevelop to crash(at least in my case).

So, the best way would probably be using ILOG.J2CsMapping project, to translate Java code into C# code directly. Though the mapping dll, ILOG.J2CsMapping.dll references System.Web( and System.Drawing), It seems rather easy to make the translated code ILOG-free. It's better than rewriting everything in C#, at least, unless you need functionalities in System.Drawing. This method is tested with both 4.3.4 and 3.5.7 pro on Mac OS X 10.8.4.

Comment
Add comment · 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
2

Answer by AM_1 · May 31, 2014 at 12:56 PM

Not sure if this will work for you but look at this thread: http://forum.unity3d.com/threads/101097-Building-project-with-IKVM-dlls-inside

The last post says to go to "Edit -> Project Settings -> Player" and then under "Other settings for PC / Mac change the API Compatibility Level from '.NET 2.0 Subset' to '.NET 2.0'" This should let IKVM reference System.Drawing.

Hope this helps (I know that this is sort of an old question, but I wont to help future readers.)

Comment
Add comment · 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

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

19 People are following this question.

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

Related Questions

Can I access Java code from Unity? 2 Answers

Use KryoNet in C# via IKVM 0 Answers

Error when extending IKVM class in C# script 0 Answers

How to remove an add? 0 Answers

Touch menu for android 1 Answer


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