WCF运行错误:添加服务失败。服务元数据可能无法访问。请确保服务正在运行并且正在公开元数据。

使用WCF写了一个小程序测试一下它的功能在运行时报错。“添加服务失败。服务元数据可能无法访问。请确保服务正在运行并且正在公开元数据。”

如下图所示:

技术分享

查了下资料把它解决了,记录一下。

解决方法:

 将web.config中的

  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>

修改为

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

即可。

   

技术分享
 1 <?xml version="1.0"?>
 2 <configuration>
 3   <system.web>
 4     <compilation debug="true" targetFramework="4.0"/>
 5     <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
 6   </system.web>
 7   <system.serviceModel>
 8     <behaviors>
 9       <serviceBehaviors>
10         <behavior>
11           <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
12           <serviceMetadata httpGetEnabled="true"/>
13           <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
14           <serviceDebug includeExceptionDetailInFaults="false"/>
15         </behavior>
16       </serviceBehaviors>
17     </behaviors>
18     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
19   </system.serviceModel>
20   <system.webServer>
21     <modules runAllManagedModulesForAllRequests="true"/>
22   </system.webServer>
23 </configuration>
View Code

 

文章来自:http://www.cnblogs.com/Yang2012/p/4448482.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3