首先写了一个Service,然后编译一下,再在Debug文件夹中运行,然后在客户端的程序中添加服务引用,提示以下错误:元数据包含无法解析的引用:“net.tcp://localhost:5351/”。
没有终结点在侦听可以接受消息的 net.tcp://localhost:5351/。这通常是由于不正确的地址或者 SOAP 操作导致的。如果存在此情况,请参阅 InnerException 以了解详细信息。如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。
我的服务端配置文件如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="WCFSample.CalculatorService" behaviorConfiguration="serbe">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5351" />
</baseAddresses>
</host>
<endpoint address="net" binding="netTcpBinding" bindingConfiguration="bd" contract="WCFSample.ICalculator" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="bd">
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serbe">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
没有终结点在侦听可以接受消息的 net.tcp://localhost:5351/。这通常是由于不正确的地址或者 SOAP 操作导致的。如果存在此情况,请参阅 InnerException 以了解详细信息。如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。
我的服务端配置文件如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="WCFSample.CalculatorService" behaviorConfiguration="serbe">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5351" />
</baseAddresses>
</host>
<endpoint address="net" binding="netTcpBinding" bindingConfiguration="bd" contract="WCFSample.ICalculator" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="bd">
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serbe">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
解决方案 »
- C# LIstView 中获得选中某一项目出现的异常
- Label显示正常为什么到了更新数据库的时候会报update语句错误?
- 用button.click事件给datagridview排序遇到一点问题
- C# 如何给未知个数的数组赋值?
- 在C#中将在文本框中输入数字转换为double数组
- 如何进行委托?
- 小问题:如何向窗体中加入控件数组呀?
- 未能加载文件或者程序集“ExcelWorkbook4,Version=1.0.0.0 Cultrue=neutral"或它的有一个依赖项,给定程序集名称或者基本
- 正则表达式简单问题:要求字符中至少有一个数字、一个大写字母和一个小写字母的正则表达式怎么写?
- 请问Winform Chart如何在运行时进行调整
- 关于.net分层问题!
- 关于datagridview 自动选中第一行的问题
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" contract="WcfService1.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>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<!-- 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>
其中:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
这一行就是添加metadata endpoint的。你可以参考,当然,也要记得相应的配置behavior。之后启动服务,成功以后,再在客户端添加服务引用。