配置部分'services'无法读取,因为它缺少一个节声明

本文关键字:声明 一个 因为 services 读取 配置部 | 更新日期: 2023-09-27 18:05:49

在Visual Studio 2012中创建了一个WCF服务。当我开始调试它时,WCF测试客户端显示了错误:

"配置节'services'无法读取,因为它缺少一个节声明"

这不是IIS问题,因为当我尝试调试服务时,我正在使用WCF测试客户端。

这是整个网络。配置文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework"
      type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      requirePermission="false"/>
    <section name="oracle.manageddataaccess.client"
      type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
  <services>
    <service name="CodigoRFID.WS_RFID">
      <endpoint address="" contract="CodigoRFID.IWS_RFID" binding="basicHttpBinding"/>
      <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
    </service>
  </services>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb"/>
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
      <provider invariantName="Oracle.ManagedDataAccess.Client"
        type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </providers>
  </entityFramework>
  <connectionStrings>
    <add name="PEDIDO.SLLCOSTO" providerName="Oracle.ManagedDataAccess.Client"
      connectionString="User Id=pedido;Password=uni_1915sll;Data Source=SLLCOSTO"/>
    <add name="Entities" connectionString="metadata=res://*/Modelo.csdl|res://*/Modelo.ssdl|res://*/Modelo.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=SLLCOSTO;PASSWORD=uni_1915sll;USER ID=PEDIDO&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <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.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </DbProviderFactories>
  </system.data>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <publisherPolicy apply="no"/>
        <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <oracle.manageddataaccess.client>
    <version number="*">
      <dataSources>
        <dataSource alias="SLLCOSTO" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.34)(PORT=1521))(CONNECT_DATA=(SID=REP)(SERVER=dedicated))) "/>
      </dataSources>
    </version>
  </oracle.manageddataaccess.client>
</configuration>

配置部分'services'无法读取,因为它缺少一个节声明

除非这是一个WCF服务部分,否则你需要为<services/>部分添加一个声明…(这部分到底是干什么用的?如果它应该是一个WCF服务部分,是不是应该在父部分命名为<system.serviceModel> ?这样的:

<system.serviceModel> <services> [content here] </services> <behaviors> [content here] </behaviors > <bindings> [content here] </bindings > </system.serviceModel>

否则,添加适当的声明:

<configuration>
  <configSections>
     <!-- For more information on Entity Framework configuration, visit 
         http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework"
       type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,
              EntityFramework, Version=6.0.0.0, Culture=neutral,
              PublicKeyToken=b77a5c561934e089"
              requirePermission="false"/>
    <section name="oracle.manageddataaccess.client"
             type="OracleInternal.Common.ODPMSectionHandler,
             Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral,
             PublicKeyToken=89b483f429c47342"/>
    <section name="services" type="" />

等。

除非你需要正确填写type属性

相关文章: