web-dev-qa-db-fra.com

Erreur 500.19 La section de configuration 'Oracle.manageddataaccess.client' ne peut pas être lue car il manque une déclaration de section

Je suis nouveau sur IIS, j'essaie de monter une application Web sur le IIS du serveur, mais au moment de son exécution, il me montre un message "La section de configuration 'Oracle. manageddataaccess.client 'ne peut pas être lu car il manque une déclaration de section ", quand je le monte sur mon ordinateur si ça marche mais quand je le passe au serveur il m'envoie le message, mon application se fait en asp mvc et je me connecte à la base de données Oracle 11g entrez la description de l'image ici

 100:   </system.data>
  101:   <Oracle.manageddataaccess.client>
  102:     <version number="*">

c'est ma webconfig

<?xml version="1.0" encoding="utf-8"?>
<!--
  Para obtener más información sobre cómo configurar la aplicación ASP.NET, visite
  https://go.Microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <configSections>
    <!-- <section name="Oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />-->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.Microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>
  </system.web>
  <system.web>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="1" />
    </authentication>
  </system.web>
  <!--<system.web>
    <customErrors mode="On" >
      <error statusCode="404" redirect="~/Error/Error404" ></error>
      <error statusCode="500" redirect="~/Error/Error" ></error>
    </customErrors>
  </system.web>-->
  <!--<system.web>
    <roleManager enabled="true" />
  </system.web>-->
  <runtime>
    <assemblyBinding xmlns="urn:schemas-Microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" />
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
      </dependentAssembly>
      <dependentAssembly>
        <publisherPolicy apply="no" />
        <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.webServer>
    <!--<modules>
      <remove name="TelemetryCorrelationHttpModule" />
      <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler" />
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
    -->
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
  <system.data>
    <DbProviderFactories>
      <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" />
    </DbProviderFactories>
  </system.data>
  <Oracle.manageddataaccess.client>
    <version number="*">
      <dataSources>
        <dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(Host=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) " />
      </dataSources>
    </version>
  </Oracle.manageddataaccess.client>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v13.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <connectionStrings>
    <add name="ProductoEntities" connectionString="metadata=res://*/Models.ProductoModel.csdl|res://*/Models.ProductoModel.ssdl|res://*/Models.ProductoModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=localhost:1521/xe;PASSWORD=andres;USER ID=ANDRES&quot;" providerName="System.Data.EntityClient" />
    <add name="MonterreyEntities" connectionString="metadata=res://*/Models.dbConnMonterrey.dbMonterreyModel.csdl|res://*/Models.dbConnMonterrey.dbMonterreyModel.ssdl|res://*/Models.dbConnMonterrey.dbMonterreyModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=myserver;PASSWORD=*******;USER ID=*******&quot;" providerName="System.Data.EntityClient" />
    <add name="MonterreyProdEntities" connectionString="metadata=res://*/Models.dbMonterreyProduccion.dbMonterreyProdModel.csdl|res://*/Models.dbMonterreyProduccion.dbMonterreyProdModel.ssdl|res://*/Models.dbMonterreyProduccion.dbMonterreyProdModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=myserver;PASSWORD=*****;USER ID=*****&quot;" providerName="System.Data.EntityClient" />
    <add name="MonterreyAndresEntities" connectionString="metadata=res://*/Models.dbMonterreyAndres.dbMonterreyAndresModel.csdl|res://*/Models.dbMonterreyAndres.dbMonterreyAndresModel.ssdl|res://*/Models.dbMonterreyAndres.dbMonterreyAndresModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=myserver;PASSWORD=*****;USER ID=*****&quot;" providerName="System.Data.EntityClient" />
    <add name="dbMonterreyREPREGEREntities" connectionString="metadata=res://*/Models.dbMonterreyProduccion.dbMonterreyREPREGERProduccion.csdl|res://*/Models.dbMonterreyProduccion.dbMonterreyREPREGERProduccion.ssdl|res://*/Models.dbMonterreyProduccion.dbMonterreyREPREGERProduccion.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=myserver;PASSWORD=*****;USER ID=*****&quot;" providerName="System.Data.EntityClient" />
    <add name="MonterreyPreProduccionEntities" connectionString="metadata=res://*/Models.dbMonterreyPreProduccion.dbMonterreyPreProduccionModel.csdl|res://*/Models.dbMonterreyPreProduccion.dbMonterreyPreProduccionModel.ssdl|res://*/Models.dbMonterreyPreProduccion.dbMonterreyPreProduccionModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=myserver;PASSWORD=******;USER ID=******&quot;" providerName="System.Data.EntityClient" />
    <add name="MonterreyREPREGERPreProduccionEntities" connectionString="metadata=res://*/Models.dbMonterreyPreProduccion.dbMonterreyREPREGERPreProduccionModel.csdl|res://*/Models.dbMonterreyPreProduccion.dbMonterreyREPREGERPreProduccionModel.ssdl|res://*/Models.dbMonterreyPreProduccion.dbMonterreyREPREGERPreProduccionModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=myserver;PASSWORD=*****;USER ID=******&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>
7
andres martinez

Utiliser <Oracle.manageddataaccess.client> élément dans web.config, il est nécessaire de l'enregistrer avec <section> ou <sectionGroup> élément à l'intérieur <configSections>. Vous devez décommenter cette partie car dans votre exemple, elle commentait toujours:

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

Si la mise en commentaire de cette ligne ne fonctionne toujours pas, remplacez-la par <sectionGroup> élément:

<sectionGroup name="Oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />

Assurez-vous également que ODP Managed Data Access est déjà enregistré en tant que référence d'assembly dans votre projet et/ou GAC (Global Assembly Cache).

7
Tetsuya Yamamoto

Je trouve plus facile de gérer moi-même les chaînes de connexion, au lieu d'accepter la modification par Oracle du fichier web.config.

Mettez en commentaire <Oracle.manageddataaccess.client> Et l'entrée <configSections> Correspondante qu'Oracle insère.

À la place, j'utilise la section Microsoft <connectionStrings> Accessible par ConfigurationManager

<connectionStrings> <clear/> <add name="DB_CONN_STRING" connectionString="Data Source=servername:1521/dbinstancename;User ID=user;Password=pwd;"/> </connectionStrings>

Puis en code, créez ma connexion avec:

using System.Configuration;
using Oracle.ManagedDataAccess.Client;

string conString = ConfigurationManager.ConnectionStrings["DB_CONN_STRING"].ConnectionString;

OracleConnection myConnection = new OracleConnection(conString);
myConnection.Open();
1
mike

Au lieu de modifier votre web.config fichier manuellement, vous pouvez également utiliser l'application OraProvCfg.exe. Exécutez le script comme ci-dessous (choisissez la version qui est installée sur votre système):

set Oracle_x64=c:\Oracle\product\12.1\Client_x64\odp.net
set Oracle_x86=c:\Oracle\product\12.1\Client_x86\odp.net
set OraProvCfg_x64=%Oracle_x64%\bin\4\OraProvCfg.exe
set OraProvCfg_x86=%Oracle_x86%\bin\4\OraProvCfg.exe

set TNS_ADMIN=C:\Oracle\network\admin
set CONFIGFILE_PATH=.../web.config


REM 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%

Si vous sautez /configfile:... puis l'application modifie le global machine.config fichier. Vous devrez peut-être également configurer /product:aspnet, courir OraProvCfg.exe et vérifiez l'impression.

Oracle Providers for .NET Configuration Utility for .NET Framework 4 : Release 4.122.1.0 Production on Do Okt 18 09:00:41 2018
Copyright (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
0