DbProviderFactories 加载Oracle.DataAccess.Client 失败
作者:C/S框架网  发布日期:2017-09-14 21:08:20
  DbProviderFactories 加载Oracle.DataAccess.Client 失败


运行 DbProviderFactories.GetFactory("Oracle.DataAccess.Client") 失败!

失败原因:Oracle.DataAccess.dll 的.NETFramework运行时版本:v2.0.50727


C# Code:

//2017-09-14测试结果:
//1.调用的目标发生了异常。
//2.未能加载文件或程序集“Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342”
// 或它的某一个依赖项。试图加载格式不正确的程序。
//_ProviderNames.Add(DbProviderType.Oracle, "Oracle.DataAccess.Client");//Provider 失败!!! 运行时版本:v2.0.50727

//来源:C/S框架网(www.csframework.com) QQ:1980854898



贴图图片


使用DbProviderFactories.GetFactory方法需要配置数据库提供者:

1.配置 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config 文件。
2.配置调用DbProviderFactories.GetFactory方法所在当前程序集的app.config文件。

配置文件参考:


C# Code:

<system.data>
<DbProviderFactories>
<add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer"
type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>

<add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle"
type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

<add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET"
type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>

<remove invariant="Oracle.ManagedDataAccess.Client"/>
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>

<add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb"
type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<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.58.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"/>

</DbProviderFactories>
</system.data>

//来源:C/S框架网(www.csframework.com) QQ:1980854898


上一篇 下一篇