2009-11-26 41 views
1

我剛剛將我的ASP.Net MVC項目從MVC 2.0 Preview 2遷移到MVC 2.0 Beta,並且我對Html.RenderAction的調用打破了,因爲在MVC 2.0中引入了新的RenderAction方法Beta版。ASP.Net 2.0和新的RenderAction方法

在下面一行:

<% Html.RenderAction("DisplayIMHandles", "UserProfile", new { userProfileId = Model.Id }); %> 

我收到以下錯誤:

<% Microsoft.Web.Mvc.ViewExtensions.RenderAction 
(this.Html, "DisplayIMHandles", "UserProfile", new { userProfileId = Model.Id }); %> 

Compiler Error Message: CS0121: The call is ambiguous between the following methods or properties:

'System.Web.Mvc.Html.ChildActionExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string, object)' and 'Microsoft.Web.Mvc.ViewExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string, object)'

我可以用任何的這2個替代品取代線解決問題

<% System.Web.Mvc.Html.ChildActionExtensions.RenderAction 
(this.Html, "DisplayIMHandles", "UserProfile", new { userProfileId = Model.Id }); %> 

我應該使用哪兩種,有什麼區別?另外,有沒有辦法解決這個問題,而不寫整個命名空間,就像我曾經擁有它?

預先感謝您。

回答

4

這將是因爲你仍然引用舊的期貨庫,現在它已經被轉移到主MVC庫(Beta),你已經在兩個地方獲得了它。

如果您想解決該問題,請下載適用於測試版的新期貨庫,並在您的項目中引用該庫,而不是舊版庫。

你可以在ASP.NET CodePlex網站上找到它。

HTHs,
Charles