system.serviceModel具有无效的子元素domainServices

时间:2012-04-20 23:33:08

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

我收到此错误,实际上不知道如何修复它:

  

元素'system.serviceModel'具有无效的子元素   'domainServices'。预期可能元素列表:'行为,   绑定,客户端,comContracts,commonBehaviors,诊断,   serviceHostingEnvironment,extensions,protocolMapping,services,   standardEndpoints,tracking,routing

配置:

<?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>

1 个答案:

答案 0 :(得分:2)

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