天天看點

Silverlight中WCF在添加引用中不能發現的問題

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>

繼續閱讀