定期我得到以下异常:
无法加载DLL 'SQLite.Interop.dll':无法找到指定的模块。(异常来自HRESULT: 0x8007007E)
我使用的是1.0.82.0。在VS2010, Win7 64操作系统下使用nuget安装。
一旦异常开始出现,它就会不断出现——在调试和发布中,在VS内部或外部运行应用程序。
阻止它的唯一方法就是退出并重新登录。不抛出异常并加载dll。 它可以工作几天,但之后又会坏掉。
有人见过这样的情况吗,有解决方案吗?
定期我得到以下异常:
无法加载DLL 'SQLite.Interop.dll':无法找到指定的模块。(异常来自HRESULT: 0x8007007E)
我使用的是1.0.82.0。在VS2010, Win7 64操作系统下使用nuget安装。
一旦异常开始出现,它就会不断出现——在调试和发布中,在VS内部或外部运行应用程序。
阻止它的唯一方法就是退出并重新登录。不抛出异常并加载dll。 它可以工作几天,但之后又会坏掉。
有人见过这样的情况吗,有解决方案吗?
当前回答
所以,我的问题是SQLite试图在WPF的设计时加载。由于我只关心x86环境,所以我将CPU首选项设置为x86环境,并将Nuget包中的SQLite.Interop.dll复制到解决方案的根目录。重新启动解决方案,所有问题都消失了。因此,如果遇到设计时问题,请将库放到解决方案的根目录中。
此外,我在运行时遇到了类似的问题,所以我必须将SQLite.Interop.dll的副本放入我的项目中,并将其设置为复制,如果它在属性中较新的。似乎x86和x64提供的文件夹是完全无用的。还需要进一步的调查,但总的来说…在你的项目中手动引用SQLite比使用Nuget包更容易。
此外,官方常见问题解答如下:
(20) When the System.Data.SQLite project is compiled and run from inside Visual Studio, why do I get a DllNotFoundException or a BadImageFormatException (for "sqlite3.dll" or "SQLite.Interop.dll") when trying to run or debug the application? When compiling and running a solution from within Visual Studio that uses the System.Data.SQLite project (including the test project), it is very important to select the correct build configuration and platform. First, managed applications to be debugged inside Visual Studio cannot use the mixed-mode assembly (i.e. because it is always compiled to the platform-specific build output directory). This is necessary to properly support building binaries for multiple platforms using the same source project files. Therefore, only the "DebugNativeOnly" or "ReleaseNativeOnly" build configurations should be selected when running a managed application from inside Visual Studio that relies upon the System.Data.SQLite assembly. These build configurations contain a custom post-build step that copies the required native assembly to the managed output directory (i.e. to enable running the managed binaries in-place). However, this post-build step will only be performed if the selected platform matches that of the operating system (e.g. "Win32" for 32-bit Windows and "x64" for 64-bit Windows). Therefore, it is good practice to double-check the selected build platform against the operating system prior to attempting to run a managed project in the solution.
https://system.data.sqlite.org/index.html/doc/trunk/www/faq.wiki#q20
其他回答
因为这个问题的复杂性,我想在这里发表。我的解决方案是回滚到。net 4.0。我已经测试了3天了,还不能让System.Data.SQLite.Core.1.0.98.0与. net 4.5或. net 4.5.1一起工作。
测试在3台计算机、2台服务器和一台开发PC上进行。我还没能找到问题的根源。我已经尝试编辑.vsproj文件。我已经将SQLite.interop.dll添加到所有文件夹中。我已经将包应用到所有GAC文件夹,并单独删除和重新应用。最终删除。
我有System.Data.SQLite.Core.1.0.98.0与。net 4.0一起工作。我打算继续尝试迁移,但我想我会先开始一个新项目,看看我是否能让它以那种方式工作。它最初是一个。net 3.5 web应用程序,在我的旅行中,我发现大量的信息仍然引用了这个框架。
即使这是一篇旧文章,我也想在这里分享我找到的解决方案: http://system.data.sqlite.org/index.html/info/54e52d4c6f
如果您不想读取所有问题,解决方案是将“msvcr100.dll”文件(可以在Windows\System32目录中找到)复制到与SQLite.Interop.dll相同的路径。
我建议阅读问题以了解原因,并在安装程序中包含该文件,但仅在错误发生时才安装它,我在安装程序选项中使其成为可选组件。
HTH, Formentz
刚刚为我做了这个:在包管理器控制台上安装-Package System.Data.SQLite.Core。
当您处于这种状态时,尝试执行Rebuild-All。如果这解决了问题,您可能会遇到与我相同的问题。
一些背景(我的理解):
SQLite has 1 managed assembly (System.Data.SQLite.dll) and several platform specific assemblies (SQLite.Interop.dll). When installing SQLite with Nuget, Nuget will add the platform specific assemblies to your project (within several folders: \x86, \x64), and configures these dlls to "Copy Always". Upon load, the managed assembly will search for platform specific assemblies inside the \x86 and \x64 folders. You can see more on that here. The exception is this managed assembly attempting to find the relevant (SQLite.Interop.dll) inside these folders (and failing).
我的情况:
我的解决方案中有两个项目;一个WPF应用程序和一个类库。WPF应用程序引用类库,类库引用SQLite(通过Nuget安装)。
对我来说,问题是当我只修改WPF应用程序时,VS试图进行部分重建(意识到依赖的dll没有改变)。在这个过程的某个地方,VS清理了\x86和\x64文件夹的内容(清除了SQLite.Interop.dll)。当我做一个完整的Rebuild-All时,VS正确地复制文件夹及其内容。
我的解决方案:
为了解决这个问题,我添加了一个Post-Build进程,使用xcopy强制将\x86和\x64文件夹从类库复制到我的WPF项目\bin目录。
或者,您可以使用构建配置/输出目录做一些更花哨的事情。
超过30个答案,但我用了不同的方法。
我有两个独立的项目。一个Windows服务,和一个Windows窗体应用程序。应用程序引用WS项目,两者都引用SQLite核心nuget包。
在构建WS项目时,有x64和x32文件夹。但在构建应用程序时,文件夹不会显示出来。
检查这里的答案,我不能让他们工作。但是我发现WS项目中有以下代码片段,而App项目中没有。我添加了它,现在文件夹显示正确。
<Import Project="..\packages\System.Data.SQLite.Core.1.0.112.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.112.0\build\net46\System.Data.SQLite.Core.targets')" />