I'm new to DNN MVC, not totally new to MVC overall.
I had to hack this code to get the module to load without an error. How could Model.Count() not exist as a method?
Error: FirstDALMVC is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: Value cannot be null. Parameter name: source ---> System.ArgumentNullException: Value cannot be null. Parameter name: source at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source) at ASP._Page_DesktopModules_MVC_FirstDALMVC_Views_Item_Index_cshtml.Execute() in d:\DNNSites\DurthalerTechSvcs\DNN8\Website\DesktopModules\MVC\FirstDALMVC\Views\Item\Index.cshtml:line 8 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.StartPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at DotNetNuke.Web.Mvc.Framework.ActionResults.DnnViewResult.ExecuteResult(ControllerContext context, TextWriter writer) at DotNetNuke.Web.Mvc.MvcHostControl.RenderModule(ModuleRequestResult moduleResult) at DotNetNuke.Web.Mvc.MvcHostControl.OnPreRender(EventArgs e) --- End of inner exception stack trace ---
Created the project from the DNN 8/9 DAL2 MVC Template. It is in DesktopModules / MVC folder BTW. Filled out Chris' Wizard. Built the module. Installed from a manifest in Host. Originally, line 8 of the Index.cshtml threw an exception, which was the bold line below.
Found another article that said to build and zip the module and install it via a Zip upload in Host Extensions. But I found I had to comment out a couple component lines in the manifest file. It's looking for a resources zip file that doesn't exist and also was looking for the project DLL in the install folder. Heck, the DLL built to the /bin folder in the website. The component entry in the manifest does have the location as 'bin' but no syntax is there to specify to look from the website root. I could get the module to load, same error however. BTW, made sure per this article to build in release mode via the config manager.
Has to be my error, some missing config step but I've followed the procedures line by line to create the project.
I looked at the definition for the model type, nothing jumps out as to what would cause the line below to blow up. I'm running DNN 08.00.04 (226), Windows 10, .Net 4.6, using Visual Studio 2015 Professional Trial version.
Looked over the critical updates. I don't see anything in this list that if missing, could cause the error.
Critical Updates:
Index.cshtml code that blows up:
@inherits DotNetNuke.Web.Mvc.Framework.DnnWebViewPage<IEnumerable<Durthaler.Modules.FirstDALMVC.Models.Item>>
@using System.Text.RegularExpressions
@using DotNetNuke.Web.Mvc.Helpers
<div id="Items-@Dnn.ModuleContext.ModuleId">
@*@if (Model.Count() == 0)*@ <-- here the error was that Model had no Count method. So commented it out.
@if (0 == 0)
{
<p>@Dnn.LocalizeString("NoItems")</p>
}
else
{
<ul class="tm_tl">
@foreach (var item in Model)<-- Obviously Model exists or the loop would break.
{
<li class="tm_t">
<h3>@item.ItemName</h3>
<div class="tm_td">@item.ItemDescription</div>
@{
if (Dnn.ModuleContext.IsEditable)
{
<div>
<a href="@Url.Action("Edit", "Item", new {ctl = "Edit", itemId = item.ItemId})">@Dnn.LocalizeString("EditItem")</a>
<a href="@Url.Action("Delete", "Item", new {itemId = item.ItemId})">@Dnn.LocalizeString("DeleteItem")</a>
</div>
}
}
</li>
}
</ul>
}
</div>