Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 找不到请求的.Net Framework数据提供程序-SQLite_C#_Sqlite_Deployment_Ado.net - Fatal编程技术网

C# 找不到请求的.Net Framework数据提供程序-SQLite

C# 找不到请求的.Net Framework数据提供程序-SQLite,c#,sqlite,deployment,ado.net,C#,Sqlite,Deployment,Ado.net,我认为sqlite很简单,但它给我带来了困难。我只想创建一个应用程序,在这个应用程序中,我可以使用ado.net实体数据类连接到sqlite数据库 在运行windows xp的虚拟计算机上测试应用程序时,我遇到了这个问题。该应用程序在我当前的计算机上运行良好,在我部署它们时也可以在我的笔记本电脑上运行 以下是虚拟计算机上发生的情况: 应用程序能够启动 应用程序能够使用System.Data.SQLite与数据库交互 应用程序无法使用ADO.NET实体数据模型连接到数据库 当我尝试连接时,出现

我认为sqlite很简单,但它给我带来了困难。我只想创建一个应用程序,在这个应用程序中,我可以使用ado.net实体数据类连接到sqlite数据库

在运行windows xp的虚拟计算机上测试应用程序时,我遇到了这个问题。该应用程序在我当前的计算机上运行良好,在我部署它们时也可以在我的笔记本电脑上运行

以下是虚拟计算机上发生的情况:

  • 应用程序能够启动
  • 应用程序能够使用System.Data.SQLite与数据库交互
  • 应用程序无法使用ADO.NET实体数据模型连接到数据库
当我尝试连接时,出现以下异常:

我知道有很多帖子都在谈论这一点,大多数帖子都说你需要下载

我已经安装了sqlite-netFx40-setup-bundle-x86-2010-1.0.79.0.exe,我遇到了同样的问题。我该怎么办


编辑 我通过添加以下内容成功建立了连接:

<system.data>
 <DbProviderFactories>
  <remove invariant="System.Data.SQLite"/>
  <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
  type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>

到我的app.config文件

问题是,现在我无法选择数据,也无法将记录插入数据库。我现在尝试插入新记录时遇到的例外情况是:

对类型为“System.Data.SQLite.SQLiteFactory”的存储提供程序实例调用“GetService”方法后返回null。存储提供程序可能无法正常运行

必须添加:

 <system.data>
    <DbProviderFactories>
     <remove invariant="System.Data.SQLite"/>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data   Provider for SQLite"
      type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
     </DbProviderFactories>
  </system.data>

到我的应用程序配置文件。现在看来:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0,Profile=Client" />
  </startup>
  <system.data>
     <DbProviderFactories>
        <remove invariant="System.Data.SQLite"/>
        <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
   type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
      </DbProviderFactories>
    </system.data>
</configuration>

在安装sqlite的位置,我必须复制

到我的程序exe所在的输出目录