【问题标题】:system.serviceModel has invalid child element domainServicessystem.serviceModel 具有无效的子元素 domainServices
【发布时间】:2012-05-02 13:08:07
【问题描述】:

我收到这个错误,真的不知道如何解决它:

元素“system.serviceModel”的子元素无效 “域服务”。预期的可能元素列表:'行为, 绑定、客户端、comContracts、commonBehaviors、诊断、 serviceHostingEnvironment,扩展,protocolMapping,服务, 标准端点、跟踪、路由

配置:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="system.serviceModel">
      <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" />
    </sectionGroup>
  </configSections>    
  <system.serviceModel>
    <domainServices>
      <endpoints>
        <!-- <add name="OData" type="System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory, System.ServiceModel.DomainServices.Hosting.OData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> -->
        <add name="soap" type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <!-- <add name="JSON" type="Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> -->
      </endpoints>
    </domainServices>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceThrottling  maxConcurrentCalls="100"  maxConcurrentSessions="100"  maxConcurrentInstances="10"  />
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
 </configuration>

【问题讨论】:

  • 该错误表明您的 system.serviceModel 部分中有一个“domainServices”部分。如果此提示不足以让您弄清楚这一点,请发布您的 web.config。
  • @GTG 好的。我刚刚更新了它。请看一看。谢谢!
  • 你检查this了吗?

标签: c# .net wcf wcf-ria-services wcf-configuration


【解决方案1】:

如果我们针对的 .Net Framework 版本比预期的旧版本,有时会出现这种错误(“system.ServiceModel 有一个无效的子元素 XXXX”)。这可以通过打开项目属性然后从应用程序选项卡修改目标框架来解决。希望这对那里的人有用。

【讨论】:

  • 你说得对,我刚刚将我所有的 Web 项目从 .Net 框架 4.5 更改为 4.6.1,我的 app.config 引用错误得到了解决!非常感谢。
猜你喜欢
  • 2015-10-27
  • 2016-10-23
  • 2021-03-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多