为何不能添加服务引用?

win20032008r2 2010-05-28 03:54:37
我写了一个wcf服务,运行服务成功,但是在客户端添加服务引用时出现以下错误?

尝试在"net.tcp://localhost:7777/Service"上查找服务时出现错误(详细信息)。

如何解决!!!!
...全文
666 20 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
distancelj 2012-07-13
  • 打赏
  • 举报
回复
问题就是加不上服务引用,没办法得到app.config文件,自然没办法修改里边的值了!
xk1126 2010-05-30
  • 打赏
  • 举报
回复
把代码贴出来唉!~~~
win20032008r2 2010-05-30
  • 打赏
  • 举报
回复
再顶!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
qiqishardgel 2010-05-30
  • 打赏
  • 举报
回复
帮顶!
gsq_0912 2010-05-30
  • 打赏
  • 举报
回复
顶下,不太懂!!
csharpwcf 2010-05-30
  • 打赏
  • 举报
回复
顶一个!!!!!!!!!!!!!!!!!!!!!
win20032008r2 2010-05-30
  • 打赏
  • 举报
回复
超晕了,这样吧,朋友们,谁能贴出一个用tcp连接的服务端,客户端程序代码,希望分别贴出用app.config配置的和代码的,非常感谢!
  • 打赏
  • 举报
回复
其实当你做过网站开发就应该知道,web服务器是根据你请求文件的后缀来区分该去调用哪一个命令处理插件的,如果url访问的仅是目录那么web服务器走什么操作流程还不明白吗?
  • 打赏
  • 举报
回复
访问.svc文件,而不是它的目录。
liuyu520hong 2010-05-29
  • 打赏
  • 举报
回复
不懂WCF,帮顶!
mayonglong 2010-05-29
  • 打赏
  • 举报
回复
试试
在C:\WINDOWS\system32\drivers\etc下hosts文件加一行:
服务地址,名称
  • 打赏
  • 举报
回复
<endpoint address="" binding="netTcpBinding" bindingConfiguration="DuplexBinding" contract="Server.ISeviceContract" />
这句后面加一行:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
win20032008r2 2010-05-29
  • 打赏
  • 举报
回复
App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="addr" value="net.tcp://localhost:7777/Service" />
</appSettings>
<system.serviceModel>
<services>
<service name="Server.Behaviors" behaviorConfiguration="MyBehavior">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="DuplexBinding" contract="Server.ISeviceContract" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceThrottling maxConcurrentSessions="10000" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="DuplexBinding" sendTimeout="00:00:01">
<reliableSession enabled="true" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>



using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Configuration;

namespace Server
{
class Program
{
static void Main(string[] args)
{
Uri uri = new Uri(ConfigurationManager.AppSettings["addr"]);
ServiceHost host = new ServiceHost(typeof(Server.Behaviors), uri);
host.Open();
Console.WriteLine("Chat service listen on endpoint {0}", uri.ToString());
Console.WriteLine("Press ENTER to stop chat service...");
Console.ReadLine();
host.Abort();
host.Close();
}
}
}

jycrystal2002 2010-05-29
  • 打赏
  • 举报
回复
看提示,就是服务没有运行啊,贴代码吧,要不看不出来是怎么了,服务没运行或者地址端口不正确
win20032008r2 2010-05-29
  • 打赏
  • 举报
回复
元数据包含无法解析的引用:“net.tcp://localhost:7777/Service”。
无法连接到 net.tcp://localhost:7777/Service。连接尝试持续了 00:00:01.0156250 时间跨度。TCP 错误代码 10061: 由于目标机器积极拒绝,无法连接。 127.0.0.1:7777。
由于目标机器积极拒绝,无法连接。 127.0.0.1:7777
如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。
win20032008r2 2010-05-29
  • 打赏
  • 举报
回复
顶!!!!!!!!!!!!!!1
win20032008r2 2010-05-29
  • 打赏
  • 举报
回复
楼上大师,小弟不懂你说的,能说的白话点吗?
  • 打赏
  • 举报
回复
原因很多
1:地址或端口不正确;
2:URI的地址不正确,即你的远程对象的Type名不正确
……

如果是用配置文件方式的,很有可能是你配置文件某个地方没配置对,建议你使用代码方法运行,容易调试
win20032008r2 2010-05-28
  • 打赏
  • 举报
回复
运行了呀!!!!
无心雨云 2010-05-28
  • 打赏
  • 举报
回复
你Service运行没有啊?

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧