"Object reference not set to an instance of an object." when trying to view "/Admin/Contents/List"

Topics: Troubleshooting
Jan 27, 2015 at 11:15 PM
My Content List page in the Orchard CMS admin stopped working. I was making a change to a content type to require the user to check a taxonomy and boom, Content List stopped working. Anyone have an idea of what could be wrong?
[NullReferenceException: Object reference not set to an instance of an object.]
   ASP._Page_Modules_Orchard_MediaLibrary_Views_Parts_Image_SummaryAdmin_cshtml.Execute() in c:\Projects\greatbasin_lcc\src\Orchard.Web\Modules\Orchard.MediaLibrary\Views\Parts\Image.SummaryAdmin.cshtml:5
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +199
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
   System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +91
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model) +33
   Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:151
   Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.<>c__DisplayClass28.<Discover>b__15(DisplayContext displayContext) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:133
   Orchard.DisplayManagement.Descriptors.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:56
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:185
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:94
   Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:86
   Orchard.DisplayManagement.Implementation.DisplayHelper.Invoke(String name, INamedEnumerable`1 parameters) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:44
   Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:29
   CallSite.Target(Closure , CallSite , Object , Object ) +193
   Orchard.Core.Shapes.CoreShapes.ContentZone(Object Display, Object Shape, TextWriter Output) in c:\Projects\greatbasin_lcc\src\Orchard.Web\Core\Shapes\CoreShapes.cs:274

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +92
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +108
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
   Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy.ShapeAttributeBindingStrategy.PerformInvoke(DisplayContext displayContext, MethodInfo methodInfo, Object serviceInstance) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Descriptors\ShapeAttributeStrategy\ShapeAttributeBindingStrategy.cs:64
   Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy.<>c__DisplayClass4.<CreateDelegate>b__3(DisplayContext context) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Descriptors\ShapeAttributeStrategy\ShapeAttributeBindingStrategy.cs:55
   Orchard.DisplayManagement.Descriptors.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:56
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:185
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:94
   Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:86
   Orchard.DisplayManagement.Implementation.DisplayHelper.Invoke(String name, INamedEnumerable`1 parameters) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:44
   Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:29
   CallSite.Target(Closure , CallSite , Object , Object ) +193
   ASP._Page_Core_Contents_Views_Content_SummaryAdmin_cshtml.Execute() in c:\Projects\greatbasin_lcc\src\Orchard.Web\Core\Contents\Views\Content.SummaryAdmin.cshtml:13
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +199
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
   System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +91
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model) +33
   Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:151
   Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.<>c__DisplayClass28.<Discover>b__15(DisplayContext displayContext) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:133
   Orchard.DisplayManagement.Descriptors.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:56
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:185
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:94
   Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:86
   Orchard.DisplayManagement.Implementation.DisplayHelper.Invoke(String name, INamedEnumerable`1 parameters) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:44
   Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in c:\Projects\greatbasin_lcc\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:29
   CallSite.Target(Closure , CallSite , Object , Object ) +193
   System.Dynamic.UpdateDelegates.UpdateAndExecute2(CallSite site, T0 arg0, T1 arg1) +255
   CallSite.Target(Closure , CallSite , Object , Object ) +279
   Orchard.Core.Shapes.CoreShapes.List(Object Display, TextWriter Output, IEnumerable`1 Items, String Tag, String Id, IEnumerable`1 Classes, IDictionary`2 Attributes, String ItemTag, IEnumerable`1 ItemClasses, IDictionary`2 ItemAttributes) in c:\Projects\greatbasin_lcc\src\Orchard.Web\Core\Shapes\CoreShapes.cs:687

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +92
Jan 27, 2015 at 11:29 PM
I forgot to add source error:
Source Error: 


Line 3:  @{
Line 4:      ImagePart imagePart = Model.ContentPart;
Line 5:      var mediaPart = ((ContentItem)Model.ContentItem).As<MediaPart>();
Line 6:  }           
Line 7:  
Coordinator
Jan 27, 2015 at 11:35 PM
It looks like you modified more than that. From the looks of it, your Image content type lost its ImagePart.
Feb 21, 2015 at 4:07 PM
One source of this error is having a content type definition that includes the image part but that does not include media part. This issue exists in 1.81.

creating a new content type
Add the image part
save the content type
click 'content' in the admin view to list your content items
it will produce the error you see

Add the media part (and set the stereotype as the onscreen instructions note)
save
view the content list - it will work

I believe that the same error occurs if add the video part without the media part and there may be other causes as well.
Feb 23, 2015 at 7:01 PM
Yes, that is correct. Adding the media part back in fixed the error, thanks!