错误500.19无法读取配置节'oracle.manageddataaccess.client',因为它缺少节声明

时间:2018-10-17 16:38:02

标签: asp.net asp.net-mvc oracle iis

我是IIS的新手,正在尝试将Web应用程序安装在服务器的IIS上,但是在运行它的同时,向我显示一条消息“配置部分'oracle.manageddataaccess.client'不能为读取,因为它缺少节声明”,当我将其安装到计算机上时,如果它可以工作,但是当我将其传递给服务器时,它会向我发送消息,我的应用程序是在ASP MVC中制作的,并且我连接到Oracle数据库11g enter image description here

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

这是我的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>

3 个答案:

答案 0 :(得分:4)

要在web.config中使用library(dplyr) # Standard dataframe iris[, "Species"] iris_tibble = iris %>% as_tibble() # Remains a tibble/dataframe iris_tibble[, "Species"] # This gives you just the vector iris_tibble[, "Species", drop = TRUE] 元素,必须在<oracle.manageddataaccess.client>内的<section><sectionGroup>元素中进行注册。您应该取消注释此部分,因为在您的示例中它仍然注释:

<configSections>

如果取消注释该行仍然不起作用,请将其更改为<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /> 元素:

<sectionGroup>

还要确保ODP托管数据访问已在您的项目和/或GAC(全局程序集缓存)中注册为程序集引用。

答案 1 :(得分:0)

除了手动编辑web.config文件之外,您还可以使用应用程序OraProvCfg.exe。执行以下脚本(选择系统上安装的版本):

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%

如果您跳过/configfile:...,则应用程序将修改全局machine.config文件。也许您还必须配置/product:aspnet,运行OraProvCfg.exe并检查打印输出。

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

答案 2 :(得分:0)

我发现自己管理连接字符串比接受Oracle对web.config文件的编辑要容易得多。

注释掉Oracle插入的<oracle.manageddataaccess.client>和相应的<configSections>条目。

相反,我使用ConfigurationManager可以访问的Microsoft <connectionStrings>部分

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

然后用代码创建我的连接:

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

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

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