Unable to find the requested .Net Framework Data Provider - SQLite

℡╲_俬逩灬. 提交于 2019-12-17 10:48:58

问题


I thought that sqlite was simple but it is giving me a hard time. I just want to create an application where I can connect to a sqlite database using the ado.net entity data classes.

I am having this problem when testing the application on a virtual computer running windows xp. the application works fine on my current computer and also on my laptop when I deploy them.

Here is what happens on the virtual computer :

  • The application is able to launch.
  • The application is able to interact with the database using System.Data.SQLite
  • The application is not able to connect to the database using The ADO.NET Entity data models

when I try to connect I get the following exception:

I know there are a lot of post that talk about this and most of them say that you need to download the .NET provider for Sqlite.

I have already installed the sqlite-netFx40-setup-bundle-x86-2010-1.0.79.0.exe and I get the same problem. What should I do?


Edit

I managed to establish a connection by adding:

<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>

to my app.config file.

The problem is that now I cannot select data nor insert records to the database. The exception that I get when I try to insert a new record now is:

A null was returned after calling the 'GetService' method on a store provider instance of type 'System.Data.SQLite.SQLiteFactory'. The store provider might not be functioning correctly.


回答1:


had to add:

 <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>

to my app config file. and it now looks like:

<?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>

In the location where sqlite was installed I had to copy

to my output directory where my program exe is located



来源:https://stackoverflow.com/questions/9725979/unable-to-find-the-requested-net-framework-data-provider-sqlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!