ODP.NET Managed - Unable to find requested .Net Framework Data Provider

半城伤御伤魂 提交于 2019-11-28 12:09:15

I would start by doing a direct test and avoiding the factory methods:

var conn = new Oracle.ManagedDataAccess.Client.OracleConnection("your connection string");
conn.Open();

Any issues here will either be related to the Oracle.ManagedDataAccess.dll missing from the bin directory, or connectivity issues caused by the connection string (assuming you can already connect to the oracle instance via other means).

As for the factory, it looks like you're using some out of date enterprise library code. In later versions of the framework I believe you would use:

var factory = DbProviderFactories.GetFactory("ODP.NET, Managed Driver");
var conn = factory.CreateConnection();

I think if you take it one step at a time you'll get better feedback.

I was getting this error when deploying an ASP.NET MVC 5 application using EntityFramework 5 to our 64-bit server on which the 64-bit version of the ODAC client components were installed.

I followed b_levitt's advise and confirmed that the connection could be opened manually without using the factories, so the ODAC was installed and working, but the factory methods were unable to locate the assemblies.

After pulling my hair for an undisclosed amount of time, I figured out that the problem was with the machine.config file for the 32-bit version of the .NET framework. It did not include the entries for the oracle providers, so I manually added the following entries to this file:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config

Under

<configuration>
  <configSections>

make sure that you have the following two section entires:

<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

You can get the exact entries from your machine.config file under the framework64 folder.

Next, under

  <system.data>
    <DbProviderFactories>

make sure that you have the following two factory names:

  <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.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  <add name="ODP.NET, Unmanaged Driver" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET, Unmanaged Driver" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />

After adding these entries, everything was working for me.

I solved mine changing the IIS Application Pool configuration for Enable 32-bit Application to FALSE.

I was getting the exception Failed to find or load the registered .Net Framework Data Provider because the ODAC I installed is for 64-bit, and my app pool was making the app run at 32-bit.

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