Error with Audit Trail

Topics: Troubleshooting
Jul 20, 2015 at 2:53 AM
Updated a site when I enable the Audit module I getting the following exception:

Any help is much appreciated.

2015-07-19 18:32:43,101 [156] Orchard.DisplayManagement.Implementation.DefaultDisplayManager - Default - ArgumentOutOfRangeException thrown from Action1 by System.Action1[[Orchard.DisplayManagement.Implementation.ShapeDisplayingContext, Orchard.Framework, Version=1.9.1.0, Culture=neutral, PublicKeyToken=null]]
http://test.ƒcom/Admin/Orchard.AuditTrail?content=27
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
at System.Linq.Enumerable.ElementAt[TSource](IEnumerable1 source, Int32 index)
at Orchard.AuditTrail.Services.DiffGramAnalyzer.<Analyze>d__3.MoveNext()
at System.Linq.Buffer
1..ctor(IEnumerable1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable
1 source)
at Orchard.AuditTrail.Providers.Content.ContentAuditTrailEventShapes.<Discover>b__10(ShapeDisplayingContext context)
at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable1 events, Action1 dispatch, ILogger logger) in z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\InvokeExtensions.cs:line 17
2015-07-19 18:32:43,289 [156] Orchard.Exceptions.DefaultExceptionPolicy - Default - An unexpected exception was caught
http://test.com/Admin/Orchard.AuditTrail?content=27
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot convert null to 'int' because it is a non-nullable value type
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at ASP._Page_Modules_Orchard_AuditTrail_Views_AuditTrailEvent_Content_SummaryAdmin_cshtml.Execute() in d:\test\Modules\Orchard.AuditTrail\Views\AuditTrailEvent-Content.SummaryAdmin.cshtml:line 8
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 z:\Builds\work\9f6cd39ff0f68f41\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 z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:line 133
at Orchard.DisplayManagement.Descriptors.ShapeAlterationBuilder.<>c__DisplayClass3.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:line 56
at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 203
at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 99
at Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 30
at CallSite.Target(Closure , CallSite , Object , Object )
at ASP._Page_Modules_Orchard_AuditTrail_Views_admin_Index_cshtml.Execute() in d:\test\Modules\Orchard.AuditTrail\Views\Admin\Index.cshtml:line 56
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 Orchard.Mvc.ViewEngines.ThemeAwareness.LayoutAwareViewEngine.<>c__DisplayClass7.<FindView>b__5(ViewContext viewContext, TextWriter writer, IViewDataContainer viewDataContainer) in z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\Mvc\ViewEngines\ThemeAwareness\LayoutAwareViewEngine.cs:line 60
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
Jul 20, 2015 at 4:04 AM
I was able to find one content item that was causing the issue. I cloned it, deleted the original and now it all seems to work fine. This was the page type so nothing special.

Thanks,
Matt
Developer
Jul 20, 2015 at 5:37 PM
Interesting. Please let us know if you can reproduce this. Thanks
Jul 20, 2015 at 9:04 PM
I was able to reproduce with one other content item, same solution seemed to clear it up.

I did a little debugging and it was this line in the view where it was failing.
Orchard.AuditTrail\Views\AuditTrailEvent-Content.SummaryAdmin.cshtml

Line 8 : var contentItemId = (int)Model.ContentItemId; (I could see this enabling .net errors to render)
I was never able to bottom this out and since the site was production I was under the gun to get it operational so did the workaround, from what I could see Model.ContentItemId was returning null.

Content Items in question were of type "page" so nothing custom or unique. The site was in the process of migrating from 1.8.1 to 1.9.1, and was just made live, it was decided to enable the Audit functionality. Sine this issue I have gone through all of the content items to ensure they can be saved/published and AuditTrail appears to work. I have also created test content items with no issue in Audit. I was unable to replicate the issue on a development site or a 3rd time on the production site.

Thanks,
Matt