Silverlight中WCF在添加引用中不能发现的问题
1.开始以为是项目添加到VSS中,文件只读导致的,把所有只读都检查了一遍后,发现问题依旧
2.上网查了一下,说是配置文件有问题,结果检查Web.config文件,发现文件内容如下
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding> //这个customBinding其实是不需要的
<binding name="PAImport.Web.wcfMain.customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="PAImport.Web.wcfMain">
<endpoint address="" binding="customBinding" bindingConfiguration="PAImport.Web.wcfMain.customBinding0"
contract="PAImport.Web.wcfMain" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
发现配置文件多了很多东西,结果找了一个项目,可以正常发现WCF的项目,看了一下web.config文件
发现,注意是<system.serviceModel>这一段,根本不需要那么多东西,直接用下面的内容替换掉,重新生成后,
WCF就能在项目中成功发现了
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>