求助WCF的配置问题

nimingxin1987 2017-09-21 05:16:26
总是在提示如下信息:
在 ServiceModel 客户端配置部分中,找不到引用协定“WcfServiceReference.IService”的默认终结点元素。这可能是因为未找到应用程序的配置文件,或者是因为客户端元素中找不到与此协定匹配的终结点元素。


app.config文件如下

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService" maxReceivedMessageSize="2147483647"/>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8000/" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService" contract="WcfServiceReference.IService"
name="WSHttpBinding_IService">
<identity>
<userPrincipalName value="XXZX-ZHANGYANG\Administrator" />
</identity>
</endpoint>
</client>
<behaviors>
<serviceBehaviors>
<behavior name="debug">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

...全文
153 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
exception92 2017-09-21
  • 打赏
  • 举报
回复
方法1:修改Client->endpoint->contract的值为 契约类路径或者服务代理中的Service类 方法2:初始化界面设计器时,Visual studio默认是从devenv.exe.config(在win7中默认路径C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config )配置文件中读取配置信息,当在界面构造函数中调用WCF服务时,devenv.exe.config中不存在WCF配置信息,可能会抛出上面的错误,你需要把WCF客户端配置信息粘贴到devenv.exe.config文件中。
nimingxin1987 2017-09-21
  • 打赏
  • 举报
回复
但此时的程序是可以跑通的

110,538

社区成员

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

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

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