2009-11-09 84 views
0

我有用.NET 4.0編寫的WCF服務庫。我有一個WCF應用程序(爲了在IIS中託管此服務)在同一個解決方案中。它包含WCF庫程序集引用和一個service.svc文件,該文件指向庫中的服務以及作爲WCF服務庫的app.config副本的web.config。 WCF應用程序被設置爲在IIS7中託管服務(虛擬目錄已設置)。同樣的解決方案包含一個ASP.NET Webforms解決方案,我已經添加了一個服務引用,指向我在IIS中託管的WCF服務(如前所述)。無法在IIS7中正確託管WCF服務

當我啓動此ASP.NET Web應用程序的一個實例時,我收到一條消息,指出「WCF服務已託管」,並且ASP.NET應用程序可以正確訪問它的數據。然而,當我嘗試訪問這個數據通過服務引用添加到一個不同的解決方案(指向IIS中託管的服務)在同一臺計算機上的MVC 2 Web應用程序,我得到一個「遠程服務器返回錯誤:( 405)方法不允許。「協議例外。但是,如果手動調用我用來從另一個解決方案託管WCF服務庫的WCF應用程序的實例,則MVC應用程序能夠訪問服務數據。

我使用VS2010 Beta 2作爲我的開發IDE。我一直堅持這個問題一段時間了。任何幫助,將不勝感激。

我服務的配置如下: -

<system.serviceModel> 
<services> 
    <service behaviorConfiguration="CruxServices.BasicSearchServiceBehavior" 
    name="CruxServices.BasicSearch.BasicSearch"> 
    <endpoint address="" binding="wsHttpBinding" name="WSBindingEndpoint" bindingConfiguration="WSBindingConfig" 
     contract="CruxServices.BasicSearch.Interfaces.IPropertyListFilter"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" name="MexEndpoint" 
     contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost/CruxServices" /> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="CruxServices.BasicSearchServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<bindings> 
    <wsHttpBinding> 
    <binding name="WSBindingConfig"> 
     <security mode="None"> 
     <transport clientCredentialType="None"/> 
     <message establishSecurityContext="false"/> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

回答

0

在IIS的配置可以指定要使用的.NET Framework的版本。

在這種情況下有4個版本的.NET Framework 1.0,1.1,2.0和4.0

你的第一個問題是IIS沒有配置爲運行框架4.0

您可能然而,你可能有一個更大的問題,我不知道,如果可能的話,你可能需要IIS 7.5

編輯

現在已經檢查了它。它將起作用,唯一需要做的是確保將框架4選作應用程序池的框架。

+0

嗨西拉,謝謝你的回覆。我正在使用IIS 7.5附帶的Windows 7盒子上運行此操作。我安裝了VS2010,因此安裝了.NET 4.0,這是一個.NET 4.0 MVC 2應用程序。 – user206736 2009-11-10 08:08:39