TargetInvocationException - Blank pages?

Topics: Core
May 25, 2015 at 7:58 AM
We have had an issue overnight where pages suddenly stopped showing. I was left with the following error:
  • EventData
    3005
    An unhandled exception has occurred.
    5/25/2015 12:42:22 AM
    5/25/2015 5:42:22 AM
    0a4f933a4c184abdb6f6614517b25748
    4
    1
    0
    /LM/W3SVC/8/ROOT-1-130770060326308518
    Full
    /
    C:\inetpub\wwwroot\MySite\Orchard\
    WWW001
3824
w3wp.exe
IIS APPPOOL\MySite
TargetInvocationException
Exception has been thrown by the target of an invocation. at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy.ShapeAttributeBindingStrategy.PerformInvoke(DisplayContext displayContext, MethodInfo methodInfo, Object serviceInstance) in c:\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeAttributeStrategy\ShapeAttributeBindingStrategy.cs:line 65 at Orchard.DisplayManagement.Descriptors.ShapeAlterationBuilder.<>c__DisplayClass3.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in c:\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:line 56 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 185 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 94 at Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 86 at Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 30 at CallSite.Target(Closure , CallSite , Object , Object ) at ASP._Page_Modules_Orchard_Widgets_Views_Widget_cshtml.Execute() in c:\inetpub\wwwroot\MySite\Orchard\Modules\Orchard.Widgets\Views\Widget.cshtml:line 1 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.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) at Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in c:\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:line 151 at Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.<>c__DisplayClass26.<>c__DisplayClass28.<Discover>b__15(DisplayContext displayContext) in c:\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:line 133 at Orchard.DisplayManagement.Descriptors.ShapeAlterationBuilder.<>c__DisplayClass3.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in c:\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:line 56 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 185 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 94 at Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 86 at Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 30 at CallSite.Target(Closure , CallSite , Object , Object ) at Orchard.Core.Shapes.CoreShapes.Zone(Object Display, Object Shape, TextWriter Output) in c:\Orchard\src\Orchard.Web\Core\Shapes\CoreShapes.cs:line 267 Cannot perform runtime binding on a null reference at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at ASP._Page_Themes_CmpasCustom_Views_Parts_MenuWidget_AsideFirst_cshtml.Execute() in c:\inetpub\wwwroot\MySite\Orchard\Themes\CmpasCustom\Views\Parts.MenuWidget-AsideFirst.cshtml:line 58 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.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) at Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in c:\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:line 151 at Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.<>c__DisplayClass26.<>c__DisplayClass28.<Discover>b__15(DisplayContext displayContext) in c:\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:line 133 at Orchard.DisplayManagement.Descriptors.ShapeAlterationBuilder.<>c__DisplayClass3.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in c:\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:line 56 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 185 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 94 at Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 86 at Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 30 at CallSite.Target(Closure , CallSite , Object , Object ) at Orchard.Core.Shapes.CoreShapes.ContentZone(Object Display, Object Shape, TextWriter Output) in c:\Orchard\src\Orchard.Web\Core\Shapes\CoreShapes.cs:line 274
http://dev.somedomain.com:8888/somepage
/somepage
xx.x.xx.xxx

False

IIS APPPOOL\MySite
14
IIS APPPOOL\MySite
False
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy.ShapeAttributeBindingStrategy.PerformInvoke(DisplayContext displayContext, MethodInfo methodInfo, Object serviceInstance) in c:\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeAttributeStrategy\ShapeAttributeBindingStrategy.cs:line 65 at Orchard.DisplayManagement.Descriptors.ShapeAlterationBuilder.<>c__DisplayClass3.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in c:\Orchard\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:line 56 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 185 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 94 at Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 86 at Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in c:\Orchard\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 30 at CallSite.Target(Closure , CallSite , Object , Object ) at ASP._Page_Modules_Orchard_Widgets_Views_Widget_cshtml.Execute() in c:\inetpub\wwwroot\MySite\Orchard\Modules\Orchard.Widgets\Views\Widget.cshtml:line 1 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.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper,
Developer
May 25, 2015 at 1:17 PM
Do you have any custom shape methods?
May 26, 2015 at 3:47 PM
I am quite new to Orchard and .NET, so I don't know the full extent of custom shapes.

I do have a number of alterations to views in my theme. The last file I changed was Orchard\Themes\MyTheme\Views\Document.cshtml.
May 26, 2015 at 3:59 PM
Actually, I reread the error and found the offending file mentioned (Parts.MenuWidget-AsideFirst.cshtml):
@*@Display(Model.Menu)*@

@functions{
    dynamic FindPageMenuItem(string currentPage, IList<dynamic> menuItems)
    {
        var result = menuItems.FirstOrDefault(i => i.Href.ToLower() == currentPage.ToLower());
        if (result != null)
        {
            return result;
        }
        else
        {
            foreach (var item in menuItems.Where(i => i.Items != null && i.Items.Count > 0))
            {
                result = FindPageMenuItem(currentPage, item.Items);
                if (result != null)
                {
                    break; 
                }
            }
            return result;
        }
    }
    
}

@{
    //var settings = WorkContext.Resolve<IThemeSettingsService>().GetSettings();

    // Model is Model.Menu from the layout (Layout.Menu)
    //Model.Classes.Add(settings.UseFixedNav ? "nav navbar-nav" : "nav nav-pills");

    var menu = Model.Menu;
    
    //menu.Classes.Add("row");
    //var tag = Tag(menu, "div");
    
    
    var items = (IList<dynamic>)Enumerable.Cast<dynamic>(menu.Items);

    if (items.Any()) {
        items[0].Classes.Add("first");
        items[items.Count - 1].Classes.Add("last");
    }

    var currentPage = WorkContext.HttpContext.Request.Url.AbsolutePath;
    var page = FindPageMenuItem(currentPage, items);
    var root = page != null ? page.Parent : page;
    
    //var searchText = new SearchViewModel();
    //if (Model.ViewModel != null) {
    //    searchText = (SearchViewModel)Model.ViewModel;
    //}

}

@*@tag.StartElement*@
<h3>@root.Text</h3>
    <ul class="list-unstyled">

@foreach (var i in root.Items)
{
    var className = i.Href.ToLower() == currentPage.ToLower() ? "cmpas-active-page" : string.Empty; 

    <li><a href="@i.Href" class="@className">@i.Text</a></li>
    @*<li>@root.GetType().GetProperties()</li>*@
}
    </ul>