简体   繁体   English

在某些计算机上,应用程序无法加载sqlite dll文件

[英]On some computers application can't load sqlite dll file

I wrote an application that uses sqlite and it works great on most of the systems. 我编写了一个使用sqlite的应用程序,它在大多数系统上运行良好。 It is written in C#, and the only non-framework assembly is sqlite, which is included by System.Data.SQLite.dll . 它是用C#编写的,唯一的非框架程序集是sqlite,它包含在System.Data.SQLite.dll中。

I deploy it the same way on all of the machines (copy pasting the exe file, the database file and the System.Data.SQLite file). 我在所有机器上以相同的方式部署它(复制粘贴exe文件,数据库文件和System.Data.SQLite文件)。 It works great for all my PC's and most of the PC's I've tried. 它适用于我所有的PC以及我尝试过的大多数PC。

But then I've got reports that for some people it throws the following exception: 但后来我得到报告说,对某些人来说,它会抛出以下异常:

Could not load file or assembly 'System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. 无法加载文件或程序集'System.Data.SQLite,Version = 1.0.65.0,Culture = neutral,PublicKeyToken = db937bc2d44ff139'或其依赖项之一。 An attempt was made to load a program with an incorrect format. 尝试加载格式不正确的程序。

Now I've made sure the dll file is in the same folder than the application exe file. 现在我已确保dll文件与应用程序exe文件位于同一文件夹中。 It's the same dll, with the same version as stated in the exception message above. 它是相同的dll,具有与上面的异常消息中所述相同的版本。

I was really confused by this, so I created a fresh virtual machine, installed windows 7 professional on it, and just copy pasted the files, and the thing worked. 我真的对此感到困惑,所以我创建了一个新的虚拟机,在其上安装了Windows 7专业版,并且只是复制粘贴文件,并且事情有效。 So if it works on a fresh windows, I can't imagine what the other PC's could be missing... 因此,如果它在一个新窗口上工作,我无法想象其他PC可能会丢失什么...

Note: Two of those machines where the project throws the exception are also running windows 7 proffesional. 注意:项目抛出异常的其中两台机器也运行Windows 7 proffesional。

I would really appreciate any help on this, because I'm fresh out of ideas... 我真的很感激这方面的任何帮助,因为我是新鲜的想法......

Here's a possibility: Is the difference between the working and not-working machines 32-bit vs. 64-bit? 这是一种可能性:工作和非工作机器之间的区别是32位还是64位? Are you building for "Any CPU", when you should be building for just the bitness of your external DLL? 您是否正在为“任何CPU”构建,当您应该构建外部DLL的位数时?

It is possible that the machines that throw the exception are running a 64-bit version of Windows and that your program is using the AnyCPU configuration. 抛出异常的计算机可能正在运行64位版本的Windows,并且您的程序正在使用AnyCPU配置。 The System.Data.SQLite DLL is a two-faced beast: a managed part and a native-part. System.Data.SQLite DLL是一个双面的野兽:托管部分和本机部分。 It could be that the native-part is responsible for the exception. 可能是本机部分负责异常。

See this question for more info. 有关详细信息,请参阅此问题

Have you checked whether the target system is 64-bit or 32-bit? 您是否检查过目标系统是64位还是32位?

It might be that one of your dependencies requires a 32-bit version of Windows. 可能是您的某个依赖项需要32位版本的Windows。 To solve the issue you can specify a platform target in the properties of your C# project: Choose x86 instead of Any CPU. 要解决此问题,您可以在C#项目的属性中指定平台目标:选择x86而不是任何CPU。

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

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