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 Bypp · Jul 15, 2014 at 08:40 PM · iosdll.netcompatibility

Using a .dll in Unity C#

I am currently working with Unity3D, and need to import a .dll file compiled in VS2008, using .net 2.0. It works perfectly well on the PC version and it works just like I want it to, but it somehow breaks my iOS build. I'm not even using the .dll on mobile devices, and the code linking to the dll (DllImport) is compiled only in the PC build.

I'm getting the following error when building for iOS :

 ArgumentException: The Assembly Microsoft.VisualC is referenced by mydll. But the dll is not allowed to be included or could not be found.

I've changed to api compatibility level (in the player settings for all platforms in unity) to .net 2.0, and built my dll targetting the 2.0 .net level as well.

Why is the dll even in my build ? What are the correct steps to import a .dll, maybe I've missed something crucial ?

QUICK EDIT : The .net api compatibility wasn't set correctly in the end for iphone, but I'm still getting some error :

 Error building Player: NullReferenceException: Object reference not set to an instance of an object

I think it's during the AOT cross compile phase of the player creation. Maybe someone knows how to deal with this ?

Also, maybe it was unclear in my question, but my DLL uses managed code to be able to access .net functions.

UPDATE : Been working on this a bit on my end, now I'm wondering if there is a way to simply exclude this .dll from my iOS build ? (apart from doing it manually everytime I want to build). I can't seem to find out a way to do this. I've tried stripping, but it doesn't work well with other parts of my application (breaks some things), and now I'm a bit lost. I can manually remove and add it as a workaround but would really like a cleaner solution !

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by stevethorne · Jul 17, 2014 at 12:55 PM

Do you have the Windows .dll in an x86 folder, or x86_64 folder? This will tell Unity that it is a Windows specific .dll. Special Folder Names

Comment
Add comment · Show 3 · 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 Bypp · Jul 17, 2014 at 01:38 PM 0
Share

@stevethorne Just tried that. Still getting a single "Error building Player: NullReferenceException: Object reference not set to an instance of an object" error, with nothing else explaining anything. It seems no matter where I put the .dll in my Assets folder, this error will occur.

avatar image stevethorne · Jul 17, 2014 at 01:57 PM 0
Share

Where you have the code referencing that dll in your scripts, do you have them wrapped in #define's for Windows only? That way the code doesn't get compiled when iOS is going?

avatar image Bypp · Jul 17, 2014 at 05:11 PM 0
Share

@stevethorne Yep, using the #if UNITY STANDALONE WIN (those spaces are underscores) tag for all code that references the .dll. First thing I checked, actually !

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

2 People are following this question.

avatar image avatar image

Related Questions

Can Unity work with a "Managed .NET assembly (NatNetML.dll) for use in .Net compatible clients"? 1 Answer

[iOS] Managed DLL cannot find references to .Net framework DLLs 1 Answer

Unable to pass aws credentials at runtime in iOS 1 Answer

What kind of devices are supported/required to run builds using .NET 4.x scripting runtime? 2 Answers

ML.NET in unity 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