2010-11-10 81 views
0

我正在使用C#作爲語言在Visual Web Developer Express Edition 2008下的Web站點項目(而不是Web應用程序)上工作。ASP.NET編譯錯誤

在網站上我有一個參考服務(服務器中的ASMX文件)。當我在本地運行應用程序,它可以顯示Default.aspx的,沒有任何問題,但是當我把它上傳到我的託管網站它給了我一個「編譯錯誤」:

Compilation Error  
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.  
Compiler Error Message: CS0234: The type or namespace name 'ServiceModel' does not exist in the namespace 'System' (are you missing an assembly reference?)  
Source Error:  
[No relevant source lines]  
Source File: App_WebReferences.doheyfto.0.cs Line: 791 

我不爲什麼它給這個錯誤,我在Web應用程序項目中使用了相同的服務引用,並且工作正常。

我嘗試手動添加對System.ServiceModel.Web的引用到我的項目中,並且還將相應的DLL文件複製到BIN文件夾,但隨後在不同的命名空間上出現錯誤,我認爲這不是解決方案,我猜測被引用的名稱空間(來自.NET Framework)應該自動添加到項目中,它不應該像那樣工作嗎?

謝謝大家提前

+0

我發現了一些有趣的東西,它看起來像網站是指的DLL從路徑我的電腦,它不是試圖使用主機提供商的計算機中的DLL – Arturo 2010-11-10 02:00:32

回答

0

System.ServiceModel只存在於.NET 3.0或更高版本。您應該確保您的託管提供商至少支持該框架的該版本。

+0

感謝Frederic,提供者支持Framework 3.5。我有另一個應用程序部署在使用3.5的同一臺服務器上,並且一切都很好。 – Arturo 2010-11-10 01:40:00

+0

而你的應用程序不是以4.0爲目標的,對吧? – 2010-11-10 01:42:04

+0

不,它的目標是3.5,我剛剛驗證,也沒有安裝.NET 4,並在本地運行良好 – Arturo 2010-11-10 01:43:11

0

確保System.ServiceModel組件也包含在正在編制的標籤的web.config - 像

<compilation defaultLanguage="c#" debug="true"> 
    <assemblies> 
    ... 
    <add assembly="System.ServiceModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
    </assemblies> 
</compilation> 
+0

謝謝,該行並未包含在編譯標籤下。我手動添加它,但出現錯誤:無法加載文件或程序集「System.ServiceModel,Version = 3.5.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089」或其某個依賴項。該系統找不到指定的文件。 – Arturo 2010-11-10 14:41:58

+0

@Curro,我的歉意 - 服務模型是3.0.0.0程序集 - 所以它應該是「System.ServiceModel,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089」 – VinayC 2010-11-11 05:13:59