2010-07-09 5 views
0

J'ai suivi le livre de Steven Sanderson appelé Pro Framework ASP.NET MVC, et je suis en cours d'exécution en une exception:MVC SportsStore: [Construire une catégorie Menu de navigation]

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: CS0121: The call is ambiguous between the following methods or properties: 'Microsoft.Web.Mvc.ViewExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string)' and 'System.Web.Mvc.Html.ChildActionExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string)'

Line 15:  </div> 
Line 16:  <div id="catagories"> 
Line 17:   <% Html.RenderAction("Menu", "Nav"); %> 
Line 18:  </div> 
Line 19:  <div id="content"> 

Mon site .Master code:

<body> 
    <div id="header"> 
     <div class="title"> 
      SPORT STORE</div> 
    </div> 
    <div id="catagories"> 
     <% Html.RenderAction("Menu", "Nav"); %> 
    </div> 
    <div id="content"> 
     <asp:ContentPlaceHolder ID="MainContent" runat="server" /> 
    </div> 
</body> 

Je remercie Je sais où est le problème. Lorsque je change Microsoft.Web.Mvc.dll de MVC1 en Microsoft.Web.Mvc.dll de MVC2, cette erreur est résolue. Mais il apparaît une autre erreur:

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 'NavLink' does not exist in the namespace 'WebUI.Controllers' (are you missing an assembly reference?)

Erreur Source:

Line 170:  
Line 171: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()] 
Line 172: public class views_nav_menu_ascx : System.Web.Mvc.ViewUserControl<IEnumerable<WebUI.Controllers.NavLink>> { 
Line 173:   
Line 174:  private static bool @__initialized; 

Alors, comment puis-je faire maintenant?

Répondre

1

Le chapitre 5, page 137:

<%@ Control Language="C#" 
Inherits="System.Web.Mvc.ViewUserControl 
<IEnumerable<WebUI.Controllers.NavLink>>" %> 

ne fonctionne pas pour moi. J'ai continué à obtenir: Le nom de type ou nom d'espace 'NavLink' n'existe pas dans l'espace de noms 'WebUI.Controllers'

J'ai dû changer "... Controllers.NavLink ..." en "... Controllers.NavController .NavLink ... "pour que cela fonctionne. Comme ceci:

<%@ Control Language="C#" 
Inherits="System.Web.Mvc.ViewUserControl 
<IEnumerable<WebUI.Controllers.NavController.NavLink>>" %> 
Questions connexes