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.

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.

There are some different answers here:

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:

Make sure your DLL is using .Net Framework 2.0 or lower. Otherwise Unity will throw an exception.