【问题标题】:Test Client error on fresh project在新项目上测试客户端错误
【发布时间】:2011-12-29 16:43:54
【问题描述】:

我正在尝试学习 WCF,并在 VS2010 中创建了一个新的 WCF 服务库项目。我没有对默认项目进行任何更改,但是当我运行它时,WCF 测试客户端显示错误。当我在浏览器中导航到元数据端点时,结果是一个空白页面。

我错过了什么?我本来希望一个全新的、未受影响的项目能够正常工作。

这是完整的错误:

错误:工具发生错误。错误:找不到配置绑定扩展“system.serviceModel/bindings/netTcpRelayBinding”。验证此绑定扩展已在 system.serviceModel/extensions/bindingExtensions 中正确注册,并且拼写正确。

服务主机似乎工作正常。

这是配置文件。就像“开箱即用”一样

 <?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="SrvLib.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8732/Design_Time_Addresses/SrvLib/Service1/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address ="" binding="wsHttpBinding" contract="SrvLib.IService1">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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>
  </system.serviceModel>

</configuration>

【问题讨论】:

  • 你能发布配置文件,包括行为、端点等吗?

标签: c# .net wcf


【解决方案1】:

此错误通常是由 .NET 框架使用的“machine.config”文件中的错误配置引起的。也许您安装了 Windows Azure SDK 并卸载它,或者 AppFabric SDK。无论如何,您在某些部分中的条目会导致这些错误。

这里是来自我的 machine.config 的绑定,位于 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config:

<bindingExtensions>
    <add name="wsHttpContextBinding" type="System.ServiceModel.Configuration.WSHttpContextBindingCollectionElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    <add name="netTcpContextBinding" type="System.ServiceModel.Configuration.NetTcpContextBindingCollectionElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    <add name="webHttpBinding" type="System.ServiceModel.Configuration.WebHttpBindingCollectionElement, System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add name="basicHttpContextBinding" type="System.ServiceModel.Configuration.BasicHttpContextBindingCollectionElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</bindingExtensions>

查看那里是否还有其他条目并将其删除。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-12-18
  • 1970-01-01
  • 1970-01-01
  • 2021-10-08
  • 2015-06-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多