Why am I getting “Unable to load DLL 'sqlite3'” in my WPF app?

后端 未结 3 1014
北海茫月
北海茫月 2021-01-12 10:46

I added what I thought were the necessary SQLite (and sqlite-net) packages to my app. On running it, though, I get an exception:

System.DllNotFoundException was u

3条回答
  •  Happy的楠姐
    2021-01-12 11:14

    Is your project build set to Any CPU? You'll need to set it to either x86 or x64 for SQLite3. The x86 route will yield more compatibility across devices, so I recommend that option unless your doing some specific 64-bit stuff.

    Edit: You'll also need to download the actual Sqlite DLL manually from Sqlite's main site. The file you want is named sqlite-dll-win32-x86-3080702.zip. Extract the DLL from that ZIP and add it to your project as a content file. Set the copy to output directory option in the properties tool window to Copy Always, and rebuild. Also ensure that your project is set to the x86 option as mentioned above.

    This should hopefully do the trick... its been a while since I've used Sqlite in a .NET application.

    Side Notes: The Nuget package you downloaded actually only contains the C# wrapper library around the real Sqlite DLL.

提交回复
热议问题