我有一个 Windows 窗体,连接到一个 sqlite 数据库。
该应用程序在我的电脑上运行良好,但是当我在任何其他电脑上运行它时,我收到消息:
could not load file or assembly 'system.data.sqlite, version=1.0.84.0. culture=neutral, publickey token=db937bc2d44ff139' or one of irs dependencies
我尝试将 App.xml 更改为:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
</configuration>
目标机器安装了 .NET 4.5,问题与 .NET 无关,因为该消息仅出现在使用 sqlite 的类上。
我已尝试安装 Visual C++ 2010 SP1 Redistributable x86,但这并没有解决问题。
但是当我安装 Visual Studio 时,它就像魅力一样工作。
我应该如何在客户端计算机上不安装 Visual Studio 的情况下运行我的应用程序?
SQLite .NET 程序集不是 .NET Framework 或 Visual C++ 2010 SP1 Redistributable x86 的一部分;您应该将它们与您的应用程序一起部署。
来自System.Data.SQLite FAQ :
The recommended way to deploy the assemblies is "application local" (i.e. copy them to the directory the application is installed to)
另外不要忘记 native 互操作 DLL;你基本上需要这样部署:
- YourApp.exe
- System.Data.SQLite.dll
- x86/SQLite.Interop.dll
- x64/SQLite.Interop.dll
我是一名优秀的程序员,十分优秀!