C# Failed to find or load the registered .Net Data

2020-02-11 08:53发布

问题:

I am using SQLite and the wrapper from http://sqlite.phxsoftware.com/ and when I add a data source to my project I get the error:

"Some updating commands could not be generated automatically, the database returned to the following error: Failed to find or load the registered .Net Framework data provider"

I have the latest .Net service pack and I have uninstalled and reinstalled the SQLite software. I have also looked other places which suggest this entry is not in the machine.config file:

  <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.27.1, Culture=neutral, PublicKeyToken=db937bc2d44ff139"/>

When I looked I didn't even find a machine.config file in the C:\WINDOWS\Microsoft.NET\Framework\v3.5 folder but I did find one in the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

Does anyone have any idea what is going on? Do I need to uninstall the entire .Net Framework and then just install the 3.5 version just to get this error to go away?

Any help would be appreciated.

Thanks.

回答1:

Can you add a direct reference to System.Data.SQLite in your application and instantiate SQLiteFactory?

We use SQLite with the dll directly in our app's bin director (not the GAC) and have this line in our Web/App.config so we're not relying on Machine.config (eases deployment).

<system.data>
    <DbProviderFactories>
        <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>


回答2:

This can also occur if the computer doesn't have the Microsoft Visual C++ 2010 installed



回答3:

You don't need visual C++ 2010...!!! Only copy "msvcr100.dll" in release folder...

The "System.Data.SQLite.dll" needs "msvcr100.dll"



回答4:

I assume you are using VS 2008. Check the Framework version you are building towards.