2012-02-19 39 views
1

升級到我的ASP.NET MVC 4開發者預覽版組件,以最新的MVC 4測試版後,將出現以下異常爲我的MVC 4個項目:ASP.NET MVC 4個Beta版休息開發者預覽項目

Could not load type 'System.Web.WebPages.DisplayModes' from assembly 
'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35'. 

... 

Exception Details: System.TypeLoadException: Could not load type 
'System.Web.WebPages.DisplayModes' from assembly 'System.Web.WebPages, 
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. 

如何我解決這個問題嗎?

更新:我安裝了新的MVC 4 Beta版的NuGet包,其中增加最合適的組件,但現在我得到的缺失DisplayModes錯誤的編譯:

The name 'DisplayModes' does not exist in the current context. 

對於下面的代碼段在Global.asax.cs

DisplayModes.Modes.Insert(0, new DefaultDisplayMode("iPhone") { ... }); 

月2日更新:解決。

+0

你有這些類型的引用?它們存在於你的機器上嗎? – gideon 2012-02-19 16:03:43

+0

@gideon,我能夠將我的程序集引用更新到最新的運行時版本(4.0.30319),但是'DisplayModes.Modes.Insert' sitll將不起作用。 「DisplayModes」的語法是否改變了? – 2012-02-19 16:14:29

+0

我的教程http://www.asp.net/mvc/tutorials/mvc-4/aspnet-mvc-4-mobile-features顯示了新的語法 – RickAndMSFT 2012-02-19 20:55:32

回答

5

DisplayModes語法已更改爲:

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iPhone") 
    { 
    ... 
    }); 
+0

感謝Resharper Decompiler,我能夠發現這一點。 MS似乎在任何地方宣傳錯誤的方法,或者我錯過了它,這有點奇怪嗎? 你是如何或在哪裏發現的? [nevermind](http://www.asp.net/mvc/tutorials/mvc-4/aspnet-mvc-4-mobile-features) – 2012-03-09 08:29:18

相關問題