Error 500.19 The configuration section 'oracle.manageddataaccess.client' cannot be read because it is missing a section declaration
To use <oracle.manageddataaccess.client>
element in web.config, it is necessary to register it with <section>
or <sectionGroup>
element inside <configSections>
. You should uncomment this part because in your example it still commented:
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
If uncommenting that line still not working, change it to <sectionGroup>
element:
<sectionGroup name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
Also make sure that ODP Managed Data Access is already registered as assembly reference in your project and/or GAC (Global Assembly Cache).
I find it easier to manage the connection strings myself, instead of accepting Oracle's edit of the web.config file.
Comment out the <oracle.manageddataaccess.client>
and corresponding <configSections>
entry that oracle inserts.
Instead, I use the Microsoft <connectionStrings>
section that can be accessed by the ConfigurationManager
<connectionStrings> <clear/> <add name="DB_CONN_STRING" connectionString="Data Source=servername:1521/dbinstancename;User ID=user;Password=pwd;"/> </connectionStrings>
Then in code, create my connection with:
using System.Configuration;using Oracle.ManagedDataAccess.Client;string conString = ConfigurationManager.ConnectionStrings["DB_CONN_STRING"].ConnectionString;OracleConnection myConnection = new OracleConnection(conString);myConnection.Open();
Instead of editing your web.config
file manually you can also use application OraProvCfg.exe
. Execute script like below (pick the version which is installed on your system):
set Oracle_x64=c:\oracle\product\12.1\Client_x64\odp.netset Oracle_x86=c:\oracle\product\12.1\Client_x86\odp.netset OraProvCfg_x64=%Oracle_x64%\bin\4\OraProvCfg.exeset OraProvCfg_x86=%Oracle_x86%\bin\4\OraProvCfg.exeset TNS_ADMIN=C:\oracle\network\adminset CONFIGFILE_PATH=.../web.configREM Delete configuration, if needed"OraProvCfg_x64" /action:unconfig /product:odpm /frameworkversion:v4.0.30319 /configfile:%$CONFIGFILE_PATH%"OraProvCfg_x86" /action:unconfig /product:odpm /frameworkversion:v4.0.30319 /configfile:%$CONFIGFILE_PATH%REM Add configuration"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\managed\common\Oracle.ManagedDataAccess.dll"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\managed\PublisherPolicy\4\Policy.4.121.Oracle.ManagedDataAccess.dll"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\managed\PublisherPolicy\4\Policy.4.122.Oracle.ManagedDataAccess.dll"%OraProvCfg_x64%" /action:config /configfile:%$CONFIGFILE_PATH% /product:odpm /frameworkversion:v4.0.30319 /providerpath:%Oracle_x64%\managed\common\Oracle.ManagedDataAccess.dll /set:settings\TNS_ADMIN:%TNS_ADMIN%"%OraProvCfg_x86%" /action:config /configfile:%$CONFIGFILE_PATH% /product:odpm /frameworkversion:v4.0.30319 /providerpath:%Oracle_x86%\managed\common\Oracle.ManagedDataAccess.dll /set:settings\TNS_ADMIN:%TNS_ADMIN%
If you skip /configfile:...
then the application modifies the global machine.config
file. Perhaps you also have to configure /product:aspnet
, run OraProvCfg.exe
and check the printout.
Oracle Providers for .NET Configuration Utility for .NET Framework 4 : Release 4.122.1.0 Production on Do Okt 18 09:00:41 2018Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.Usage:OraProvCfg /action:<action> [/force] [/configfile:<app/web.config file path] [/product:<product>] [/component:<component name>] [/productversion:<product version>] [/frameworkversion:<.NET version>] [/providerpath:<provider path>] [/verbose:<verbose>] [/log:<log file path>] [/set:[*\]<section name>\<attribute name>:<attribute value>] [/unset:[*\]<section name>\<attribute name>:<attribute value>] <action> = gac | ungac | register | unregister | config | unconfig <configfile> = complete file path of app/web.config for configuring/ unconfiguring odp/odpm/ASP.net entries only. <product> = odp | odpm | aspnet <component name> = oraclepermission | perfcounter | dbproviderfactory (for odp or odpm only) = all (default) | membership | profile | sitemap | rolemanager | personalization | webevent | a combination (i.e. "membership|profile") (for aspnet only) <product version> = 4 digit assembly version number of the product (i.e. 4.112.2.0) <.NET version> = .NET Framework version (i.e. v2.0.50727 or v4.0.30319) <provider path> = full path location of the .NET assembly, including the the assembly file name (i.e. c:\OH\odp.net\bin\4\Oracle.DataAccess.dll) <verbose> = true (default) | false <log file name> = full path of the log file to log output <section name> = subsection name of oracle.manageddataaccess .client (e.g.)distributedTransaction <attribute name> = attribute name (e.g.)oramts_sess_txntimetolive <attribute value> = attribute value (e.g.)240