This project is read-only.

Another problem with StandaloneTable.cshtml

Jun 27, 2013 at 1:28 PM
Edited Jun 27, 2013 at 1:32 PM
I'm having another problem with the generic StandaloneTable.cshtml view under Shared.

I have the following action:
        public IQueryable<VehicleRetailer> ListVehicleRetailers(
            [Optionally]
            string smartFilter)
        {
              //...
        }
When i have it on a Repository registered in MenuServices, it works fine, displaying the results with StandaloneTable.cshtml.

But, if I have that same method defined on
public class Abc : IViewModel { //...}
And the instance of it is created like so:
this.Container.NewViewModel<Abc>();
Then it throws a null ref exception when I invoke the action and click Ok, whether I enter a parameter value or not.
Exception Details: System.ArgumentNullException: Value cannot be null.
on this line: @(Html.Collection(Model.Result, Model.Action))
Source File: .\Views\Shared\StandaloneTable.cshtml
I ran it in a fresh / raw MVC runner also, and it does the same in StandaloneTable.aspx

The full stack trace
System.ArgumentNullException was unhandled by user code
  HResult=-2147467261
  Message=Value cannot be null.
Parameter name: source
  Source=System.Core
  ParamName=source
  StackTrace:
       at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
       at NakedObjects.Core.Persist.ViewModelOid.ToEncodedStrings()
       at NakedObjects.Architecture.Adapter.StringEncoderHelper.Add(IEncodedToStrings item)
       at NakedObjects.Core.Persist.CollectionMemento.ToEncodedStrings()
       at NakedObjects.Core.Persist.CollectionMemento.ToShortEncodedStrings()
       at NakedObjects.Web.Mvc.Html.FrameworkHelper.Encode(IEncodedToStrings encoder)
       at NakedObjects.Web.Mvc.Html.FrameworkHelper.GetObjectId(IOid oid)
       at NakedObjects.Web.Mvc.Html.FrameworkHelper.GetObjectId(INakedObject nakedObject)
       at NakedObjects.Web.Mvc.Html.CommonHtmlHelper.GetStandalone(HtmlHelper html, INakedObject collectionNakedObject, Func`2 filter, Func`2 order, TagBuilder tag, Boolean withTitle)
       at NakedObjects.Web.Mvc.Html.CommonHtmlHelper.GetStandaloneList(HtmlHelper html, INakedObject collectionNakedObject, Func`2 order)
       at NakedObjects.Web.Mvc.Html.CollectionExtensions.CollectionListInternal(HtmlHelper html, IEnumerable collection, INakedObjectAction action)
       at NakedObjects.Web.Mvc.Html.CollectionExtensions.Collection(HtmlHelper html, IEnumerable collection, INakedObjectAction action, String defaultTo)
       at ASP._Page_Views_Shared_StandaloneTable_cshtml.<Execute>b__1() in c:\Git\Smd\Smd.Core\SMD.Core.Mvc4Runner\Views\Shared\StandaloneTable.cshtml:line 15
       at System.Web.WebPages.WebPageBase.<>c__DisplayClassb.<RenderSection>b__9(TextWriter tw)
       at System.Web.WebPages.HelperResult.WriteTo(TextWriter writer)
       at System.Web.WebPages.WebPageBase.Write(HelperResult result)
       at ASP._Page_Views_Shared_Site_WithServices_cshtml.Execute() in c:\Git\Smd\Smd.Core\SMD.Core.Mvc4Runner\Views\Shared\Site.WithServices.cshtml:line 40
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
       at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
       at System.Web.WebPages.WebPageBase.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer)
       at System.Web.WebPages.HelperResult.WriteTo(TextWriter writer)
       at System.Web.WebPages.WebPageBase.Write(HelperResult result)
       at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body)
       at System.Web.WebPages.WebPageBase.PopContext()
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
       at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
       at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
       at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
  InnerException: 
Jun 28, 2013 at 5:16 PM
This is a bug. I've raised a ticket.
Jun 28, 2013 at 5:41 PM
Thank you much.