简体   繁体   English

Mono SQLite上的System.DllNotFoundException

[英]System.DllNotFoundException on Mono SQLite

I've been trying to figure this out lately. 我最近一直想弄明白这一点。 It is working on my Windows machine, where I got SQLite from NuGet, but... 它正在我的Windows机器上工作,我从NuGet获得了SQLite,但......

When I put System.Data.SQLite.dll and SQLite.Interop.dll straight from my Windows machine into Linux server it says that SQLite.Interop.dll is not found, but I am sure I see it next right to executable. 当我将System.Data.SQLite.dllSQLite.Interop.dll从我的Windows机器直接放入Linux服务器时,它说没有找到SQLite.Interop.dll ,但我确信我在下一个可执行文件中看到了它。

Then I tried to compile System.Data.SQLite.dll with /p:UseInteropDll=false , but with no luck. 然后我尝试使用/p:UseInteropDll=false编译System.Data.SQLite.dll ,但没有运气。 This time it says that System.Data.SQLite.dll is not found. 这次它说没有找到System.Data.SQLite.dll

What is this "not found" mystery? 这个“未被发现”的谜团是什么?

No code changes necessary. 无需更改代码。 You can build it yourself. 你可以自己构建它。

  1. apt-get install build-essentials unzip
  2. Download the SQLITE source code - you want the full source code. 下载SQLITE源代码 - 您需要完整的源代码。 Currently called sqlite-netFx-full-source-1.0.104.0.zip . 目前称为sqlite-netFx-full-source-1.0.104.0.zip
  3. unzip and cd Source , unzipcd Source
  4. chmod +x the compile-interop-assembly-release.sh build shell script, then run it ./compile-interop-assembly-release.sh . chmod +x compile-interop-assembly-release.sh构建shell脚本,然后运行它./compile-interop-assembly-release.sh - It'll build an .so file in the ../bin directory. - 它将在../bin目录中构建一个.so文件。
  5. Copy this .so file to the directory that has your application in 将此.so文件复制到您的应用程序所在的目录中
  6. Run your application as normal. 正常运行您的应用程序。
  7. Note: Ensure that your SQLite database and the directory it's inside of are writable by the user you're trying to run as. 注意:确保您的SQLite数据库及其内部的目录可由您尝试运行的用户写入。

Use Mono.Data.SQLite.dll on Linux. 在Linux上使用Mono.Data.SQLite.dll Take a look at the Mono manual to using SQLite on Linux or build the System.Data.SQLite.dll on Mono . 看看Mono手册在Linux使用SQLite在Mono 构建System.Data.SQLite.dll

You can also map the DLL: 你也可以映射DLL:

<configuration>
  <dllmap dll="sqlite" target="libsqlite.so.0" os="linux"/>
  <dllmap dll="sqlite" target="libsqlite.0.dylib" os="osx"/>
  <dllmap dll="sqlite3" target="libsqlite3.so.0" os="linux"/>
  <dllmap dll="sqlite3" target="libsqlite3.0.dylib" os="osx"/>
</configuration>

I started the development in Windows, but then moved the application to Mono (Ubuntu 14), which is where the SQLite provider failed to load as OP described. 我在Windows中开始开发,但随后将应用程序移动到Mono(Ubuntu 14),这是SQLite提供程序无法按OP描述加载的地方。

I had to recompile the System.Data.SQLite.dll using the following command: 我不得不使用以下命令重新编译System.Data.SQLite.dll:

MSBuild System.Data.SQLite.2012.csproj /t:Rebuild /p:UseInteropDll=false /p:UseSqliteStandard=true 

However, after this I've got the following exception: 但是,在此之后我得到以下异常:

The provider did not return a ProviderManifest instance. 提供程序未返回ProviderManifest实例。 Method System.Data.SQLite.UnsafeNativeMethods:GetSettingValue (string,string)' is inaccessible from method System.Data.SQLite.EF6.SQLiteProviderManifest:GetProviderManifestToken (string)' 方法System.Data.SQLite.UnsafeNativeMethods:GetSettingValue (string,string)' is inaccessible from method System.Data.SQLite.EF6.SQLiteProviderManifest获取:GetProviderManifestToken(string)'

To fix this, I had to recompile the System.Data.SQLite.EF6.dll using the following command: 要解决这个问题,我不得不使用以下命令重新编译System.Data.SQLite.EF6.dll:

MSBuild System.Data.SQLite.EF6.2012.csproj /t:Rebuild /p:UseInteropDll=false /p:UseSqliteStandard=true

After copying all of the generated files to Mono project's bin directory, everything worked. 将所有生成的文件复制到Mono项目的bin目录后,一切正常。

The SQLite provider source code version I had used was 1.0.98.1. 我使用的SQLite提供程序源代码版本是1.0.98.1。

Hope this saves someone a lot of time... 希望这能节省很多时间......

I tried all the above option but those options could not solve SQLite DLL problem, It may be because I am using ubuntu 18 version, So tried other option and here the steps, 我尝试了以上所有选项,但这些选项无法解决SQLite DLL问题,可能是因为我使用的是ubuntu 18版本,所以尝试了其他选项,这里的步骤,

1) Download SQLite source code from the https://system.data.sqlite.org/downloads/1.0.111.0/sqlite-netFx-full-source-1.0.111.0.zip 1)从https://system.data.sqlite.org/downloads/1.0.111.0/sqlite-netFx-full-source-1.0.111.0.zip下载SQLite源代码

2) unzip source code and cd to unzip directory 2)解压缩源代码和cd到解压缩目录

3) Run the following command in the terminal, 3)在终端中运行以下命令,

xbuild /p:Configuration=Release /p:UseInteropDll=false /p:UseSqliteStandard=true ./System.Data.SQLite/System.Data.SQLite.2010.csproj xbuild / p:Configuration = Release / p:UseInteropDll = false / p:UseSqliteStandard = true ./System.Data.SQLite/System.Data.SQLite.2010.csproj

4) Above command would create a dll file at following path, 4)上面的命令将在以下路径创建一个dll文件,

sqlite-netFx-full-source-1.0.111.0/bin/2010/ReleaseMonoOnPosix/bin sqlite的-NETFX - 全源1.0.111.0 /斌/ 2010 / ReleaseMonoOnPosix /箱

5) Copy System.Data.SQLite.dll to your project bin folder. 5)将System.Data.SQLite.dll复制到项目bin文件夹。

6) Clean project and build again. 6)清理项目并重新构建。

I hope this would help. 我希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM