- Home /
Why does my DLL only throw a DllNotFoundException in the Editor?
I'm using sqlite3, both x86 and x86_x64. Unity version is 5.3.0f4.
The dlls are in Assets/Plugins/x86 and Assets/Plugins/x86_64 as they should be, but regardless of what I do the Editor doesn't seem to recognize the DLL. I get the DllNotFound Exception whenever my code attempts to .Open the db stored in a file.
When I build the project, however, everything runs fine and the correct version of the DLL is used.
I've checked to make sure they are marked native and checked x86/x86_x64 as appropriate. Both DLLs do actually exist in the file system as well.
I have attempted reopening my C# project, reimporting assets, and setting mono.data.sqlite (in the plugins folder) import settings for standalone to x86 and x86_x64 with no luck.
I've found answers to the opposite of this question, but no answers in those were able to apply to my situation.
When you re imported your assets, did you re import ALL assets or only certain ones?
Answer by chrisholdem · Dec 14, 2015 at 09:41 PM
After being stumped for days, a solution was found.
Noting first that re-importing any set of assets did not work. The best solution was to take the files completely out of the project, and import them fresh.
So far as I can tell there appears to be an issue with the .meta files between 5.2 and 5.3, as this only occurred after updating and the only major difference between my files now and before fixing appears to be with the .meta files.
I was sharing my unity project with my $$anonymous$$ac and a virtual instance of Windows 10. When the virtual instance opened the project, it messed something up. I deleted an asset (in my case SpaceNavigator) and the error stopped.
Answer by mgstauff · Mar 30, 2020 at 07:18 PM
There are some different answers here: https://stackoverflow.com/questions/10003028/dllnotfoundexception-in-unity3d-plugin-for-c-dll
What worked for me - for running from Editor, you need a copy of the dll in the project top folder (ie next to the Assets folder). For a build, you need to manually copy the dll to the build top level folder after the build, even though it does get put properly in the Plugins folder in the build.
And for IL2CPP builds and managed code, you may need a link.xml file to prevent stripping: https://docs.unity3d.com/Manual/IL2CPP-BytecodeStripping.html
Answer by Riderfan · Dec 13, 2015 at 01:40 AM
Make sure your DLL is using .Net Framework 2.0 or lower. Otherwise Unity will throw an exception.
Your answer
Follow this Question
Related Questions
How to include gdiplus.dll to a build? 1 Answer
how can I remote sqlite from android to pc/standalone after build? 0 Answers
Why I can not run Unity 2017.1.1 f 1 with the Command line in macOS? 0 Answers
Sqlite3.dll not found on specific Android devices 2 Answers
DllNotFoundException: sqlite3 Android 6 Marshmallow 4 Answers