设置:ASP .NET MVC 1
问题:
当ASP .NET命中RenderPartial(“Openings”...)行时,抛出异常(“无法加载类型'System.Web.Mvc.ViewUserControl(IEnumerable(OpenSpace))'。”)即使视图存在并且正在传入正确的模型。视图都在View文件夹中,在这种情况下,它们甚至位于相同的子目录中。
查看:
<%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="CommonClasses" %>
<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
Date, Time, and Furniture Arrangement
</asp:Content>
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
<div id="floattext">
<h1>
Date, Time, and Furniture Arrangement</h1>
<div id="content">
<% Using Html.BeginForm%>
<div id="left">
<% Html.RenderPartial("DateTimeAndArrangement")%>
</div>
<div id="right">
<% Html.RenderPartial("Openings", New List(Of OpenSpace))%>
</div>
<% End Using%>
</div>
</div>
</asp:Content>
DateTimeAndArrangement视图正确显示,所以我只发布了Openings的代码:
<%@ Import Namespace="CommonClasses" %>
<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(of IEnumerable(of OpenSpace))" %>
<% If Model.count = 0 Then%>
<p>
There are no open spots that match the event's requirements.</p>
<% Else%>
'Make a big clickable table with fancy AJAX magic
<% End If%>
自己注意:rev 134
答案 0 :(得分:0)
在视图的第一行(查看声明)中尝试此操作:
Inherits="System.Web.Mvc.ViewPage(of IEnumerable(of OpenSpace))"
答案 1 :(得分:0)
“无法加载类型”表明ASP.NET编译器无法找到声明OpenSpace的程序集。有几件事要尝试:
我的猜测很可能是这个问题:
Inherits="System.Web.Mvc.ViewUserControl(of IEnumerable(of MyNamespace.OpenSpace))"