2012-02-27 69 views
41

身邊,我剛安裝的MVC 4 Beta版現在我的MVC 3應用程序不與下面的錯誤編譯:MVC 4 Beta版並排安裝錯誤

The type 'System.Web.Mvc.ModelClientValidationRule' exists in both 'c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll' and 'c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\System.Web.WebPages.dll' C:\Users\michaeljo\Documents\src\patientgive\Phc.Mvc\Infrastructure\PasswordStrengthAttribute.cs

它會出現在這個已被移動到不同的組裝和因爲這兩個程序集都在GAC中,所以它不知道要使用哪個程序集。

回答

72

今天安裝MVC4測試版後,我的一些MVC 3項目無法編譯。 (ModelClientValidationRule衝突)此修復程序是:

編輯:

ProjectName.csproj 

變化

<Reference Include="System.Web.WebPages"/> 

<Reference Include="System.Web.WebPages, Version=1.0.0.0, 
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/> 
+0

它會使用MVC beta或MVC 3進行此更正嗎? – MSajjadi 2012-07-30 05:54:29

+0

mvc 3,而不是beta – 2012-07-30 07:36:08

+0

Tnx很多@tomstickel – MSajjadi 2012-08-14 06:23:18

4

好的嘗試這種解決方案

在根Web.co nfig文件,使用關鍵的webPages:Version和值1.0.0.0添加一個新條目。

2.在解決方案資源管理器中,右鍵單擊項目名稱,然後選擇卸載項目。然後再次右鍵單擊該名稱並選擇編輯ProjectName.csproj。

3.找到下面的程序集的引用:

<Reference Include="System.Web.WebPages"/> 
<Reference Include="System.Web.Helpers" /> 

用以下替換它們:

<Reference Include="System.Web.WebPages, Version=1.0.0.0, 
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/> 
<Reference Include="System.Web.Helpers, Version=1.0.0.0, 
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/> 

4.Save的變化,關閉項目(.csproj的)文件你正在編輯,然後右鍵單擊該項目並選擇重新加載。

REFERENCE

也儘量this

我發現這個答案here我第二編輯與第一組合解決了這個問題。

2

只要刪除System.Web.WebPages的引用即可。這將成功建立您的項目。