Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle ODP.NET error

I have a VS 2012 Web Project Up. I have ODP.NET installed as we are an Oracle Workshop. I inherited a project that uses Oracle.ManagedAccess.Data and EF.

Upon running the project in VS 2012, I get the following error:

There is a duplicate 'oracle.manageddataaccess.client' section defined..

The solution was to disable the following line in web.config

<!--<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />-->

Which was fine. The project compiled but upon executing a simple command such as getting a password back where it has to read the database another error was tripped up:

System.Data.ConstraintException: Column 'InvariantName' is constrained to be unique.  Value 'Oracle.ManagedDataAccess.Client' is already present.

Now I'm aware that the error is tripped up by ODP.NET and having it exist in the GAC thus the double error reporting.

Is there another line I should be commenting out or is there a way to disable ODP.NET briefly? I don't want to install that client as I use it for other projects.

thanks

like image 433
dawriter Avatar asked Oct 23 '15 23:10

dawriter


People also ask

What is ODP Net Oracle?

Oracle Data Provider for . NET (ODP.NET) features optimized ADO.NET data access to the Oracle database. ODP.NET allows developers to take advantage of advanced Oracle database functionality, including Real Application Clusters, self-tuning statement cache, Application Continuity, and Fast Connection Failover.

Does ODP net require Oracle client?

Net native implementation of ODP.NET. That means no Oracle Client is needed, and now native code is behind the scenes.


2 Answers

I found the following on the Oracle site regarding the "There is a duplicate 'oracle.manageddataaccess.client' section defined.":

If your application is a web application and the above entry was added to a web.config and the same config section handler for "oracle.manageddataaccess.client" also exists in machine.config but the "Version" attribute values are different, an error message of "There is a duplicate 'oracle.manageddataaccess.client' section defined." may be observed at runtime. If so, the config section handler entry in the machine.config for "oracle.manageddataaccess.client" has to be removed from the machine.config for the web application to not encounter this error. But given that there may be other applications on the machine that depended on this entry in the machine.config, this config section handler entry may need to be moved to all of the application's .NET config file on that machine that depend on it.

I hope it helps.

like image 51
Alex R. Avatar answered Oct 22 '22 06:10

Alex R.


I was getting the same error for an ASP.Net MVC project. I found that there is a version mismatch for oracle.manageddataaccess.client in the Web.config of the project, and machine.config in

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config, and 
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config. 

I had Version=4.122.18.3 in the Web.config and Version=4.122.1.0 in the machine.config.

I updated the version(replaced Version=4.122.1.0 of oracle.manageddataaccess.client with 4.122.18.3) in both the machine.config, and the problem resolved.

like image 41
Yasir Arafat Avatar answered Oct 22 '22 06:10

Yasir Arafat