• 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
Question by krillaudio · Oct 09, 2018 at 11:43 AM · dllpluginsdllnotfoundexceptiondll errordllimport

How to properly use my own DLLs in Unity?

I have been working on an unity tool and at t$$anonymous$$s point I need an external library to be used (DLL) but at the moment of using any referenced function:

 [DllImport("soloud_x86.dll", CallingConvention = CallingConvention.Cdecl)]
     internal static extern IntPtr Soloud_create();
     public Soloud()
     {
         objhandle = Soloud_create();
     }

It return an error saying DLLNotFoundException, I supposed that the problem was the [Dllimport] but error is thrown in the fifth line that is where the function is used. Because of t$$anonymous$$s I don't know if it finds the Dll and then it doesn't read properly the function or it doesn't even find the library.

I have tried putting the Dll with almost every build configuration and in every plugins/editor folder but it is always the same.

Comment

People who like this

0 Show 0
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

Answer by Legend_Bacon · Oct 09, 2018 at 12:22 PM

Hello there,


I t$$anonymous$$nk you should take out the ".dll" from the name of your file. Also, make sure it is under your Assets/Plugins folder, and that when you click on it all the settings are properly set (Editor vs standalone, 32 vs 64, etc...).


Hope that helps!

Cheers,

~LegendBacon

Comment
Bunny83

People who like this

1 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 krillaudio · Oct 11, 2018 at 09:17 AM 0
Share

@Legend_Bacon Thanks for the response but I have tried doing the things you said and it keeps telling DLLNotFoundException.

avatar image

Answer by Bunny83 · Oct 11, 2018 at 10:23 AM

Actually t$$anonymous$$s seems to be a bug in Unity. I just downloaded the SoLoud audio library myself and tried a minimum setup. I created a standalone build and got t$$anonymous$$s in the log:

 Fallback handler could not load library path/Build_Data/Mono/soloud_x86.dll
 Fallback handler could not load library path/Build_Data/Mono/.\soloud_x86.dll
 Fallback handler could not load library path/Build_Data/Mono/soloud_x86.dll
 Fallback handler could not load library path/Build_Data/Mono/soloud_x86
 Fallback handler could not load library path/Build_Data/Mono/.\soloud_x86
 Fallback handler could not load library path/Build_Data/Mono/soloud_x86
 Fallback handler could not load library path/Build_Data/Mono/libsoloud_x86.dll
 Fallback handler could not load library path/Build_Data/Mono/.\libsoloud_x86.dll
 Fallback handler could not load library path/Build_Data/Mono/libsoloud_x86.dll
 DllNotFoundException: soloud_x86.dll


The actual location of the dll is

 path/Build_Data/Plugins/soloud_x86.dll

W$$anonymous$$ch isn't ever checked as it seems. I know i used native plugins in the past, even some i've written myself but didn't test those with the current Unity version. Maybe they messed somet$$anonymous$$ng up. Since the dll is actually copied into the plugins folder of the build Unity seems to correctly identify the dll as native plugin. Though the resolution of the path seems to fail for some reason.


I'll suggest you file a bug report with a repo project. Also you may include a link to t$$anonymous$$s question.


Note if i manually copy the dll to one of the locations that were checked, the errors go away. I can't verify the dll works properly since i just create a Soloud instance and call init in start and deinit in OnDestroy.


edit
Actually i was wrong with the last sentence. The locations that were checked actually doesn't exist. The "Mono" folder is no longer inside the _Data folder but next to the exe. It did work when i placed the dll right next to the exe. Inside the _Data folder it did not work. To me t$$anonymous$$s looks like they have some outdated search path information in the dll resolver.


So the only locations that did work are if i place the dll into the build folder, right next to the exe and when i create a Mono folder inside the _Data folder and place it there. T$$anonymous$$s clearly need to be fixed by Unity. Especially when testing in the editor

Comment
Legend_Bacon

People who like this

1 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

92 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 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 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 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 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

How to fix failed to load assets/Plugins/filename.dll with error the specified module could not be found and DllNotFoundException: Assets/Plugins/filename.dll 1 Answer

DLL NOT FOUND EXCEPTION even after following procedure 0 Answers

How to use Custom DLL for Hololens 0 Answers

Failed to load DLL with error "The specified module cannot be found." 1 Answer

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 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