string constr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=spp01)(PORT=1521))(CONNECT_DATA=(SID=Global)));User
Id=SYSMAN;Password=testman3"; string ProviderName = "Oracle.DataAccess.Client";
DbProviderFactory factory = DbProviderFactories.GetFactory(ProviderName);
I am able to connect to oracle in console and winforms application. The code above is in a seperate class library. I have installed 64bit ODAC.
The ORACLE.DATAACCESS is set to 2.x ver 2.112.3.0. I have checked machine.config entries Framework64 v2.0.50727 and v4.0.30319
type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
CPU = Any CPU Framework=3.5
When I call the same code from class library in ASP.net then I get the following error
System.ArgumentException was unhandled by user code Message=Unable to find the requested .Net Framework Data Provider. It may not be installed. Source=System.Data StackTrace: at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
I have even set the apppool to allow 32-bit applications.
How do I resolve this error?
The error shows that the Oracle client is not installed on your system. To validate it you can run the line of code below:
System.Data.Common.DbProviderFactories.GetFactoryClasses()
You will get a DataTable of all the installed data providers. If Oracle.DataAccess.Client invarient is not listed in the DataTable then it means it is not installed.
I was also facing the same issue on one of our clients machine and on debugging i found that the Oracle client was installed from the Admin user and they were trying to access it from some other user.
On installing the Oracle client from current user resolves the problem.
Please don't forget to restart your application after installing the Oracle client.
You simply need the data provider. I had the same problem with Oracle 11g when deploying to a Windows Server 2008 R2 and after installing their data provider on the server it worked. Didn't work on the first shot though I had to restart the web app a few times.
To check if you have the ODAC on the server simply dump this string to a log somewhere or anywhere you can see it:
private String GetDbProviders()
{
// Retrieve the installed providers and factories.
DataTable table = DbProviderFactories.GetFactoryClasses();
StringBuilder bob = new StringBuilder();
// Display each row and column value.
foreach (DataRow row in table.Rows)
{
foreach (DataColumn column in table.Columns)
{
bob.AppendLine(" "+row[column]+" ");
}
}
return bob.ToString();
}
This is one of the common issues that all .NET developer who ever using the Oracle Client as Database will face.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With