0

我们有一个客户端的 Sitecore 站点,该站点抛出似乎与 MVC 和/或 Glassmapper 相关的错误。它发生在内容交付服务器上,在负载测试期间处于某些负载下(不是大量的)。它似乎发生在网站第一次编译时。在此事件之前,我们会关闭站点核心(“HostingEnvironment 启动关闭”),当它重新启动主视图中命中的第一行代码时会引发错误。如果我删除该行,那么错误之后的行等,一直到页面下方。就好像没有代码可以运行,就像重新启动时某些东西会损坏一样。如果我重置 IIS,问题就会消失。当然,除了 Razor 视图之外,我们所有的代码都在 DLL 中编译。

我知道这是一个很大的问题,但如果有人遇到过这样的问题或有任何想法去哪里看,将不胜感激!

这是堆栈跟踪:

Exception: System.Web.HttpUnhandledException
Message: An unhandled exception occurred.
Source: Sitecore.Mvc
   at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.ShowErrorMessage(ExceptionContext exceptionContext, ExceptionArgs args)
   at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.Process(ExceptionArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
   at Sitecore.Mvc.Filters.PipelineBasedRequestFilter.OnException(ExceptionContext exceptionContext)
   at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at Sitecore.Mvc.Controllers.SitecoreActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.<>c__DisplayClass22.<BeginExecuteCore>b__1e()
   at System.Web.Mvc.Async.AsyncResultWrapper.<.cctor>b__0(IAsyncResult asyncResult, Action action)
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at Sitecore.Mvc.Routing.RouteHttpHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Nested Exception

Exception: System.InvalidOperationException
Message: Error while rendering view: '/Views/Chrome.cshtml' (model: 'Castle.Proxies.IPageBaseProxy, DynamicProxyGenAssembly2').

Source: Sitecore.Mvc
   at Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer)
   at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)
   at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
   at Sitecore.Mvc.Presentation.RenderingView.Render(ViewContext viewContext, TextWriter writer)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 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(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)

Nested Exception

Exception: System.IndexOutOfRangeException
Message: Index was outside the bounds of the array.
Source: System.Core
   at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value)
   at System.Collections.Generic.HashSet`1.Add(T item)
   at Glass.Mapper.Sc.DataMappers.SitecoreFieldStringMapper.GetField(Field field, SitecoreFieldConfiguration config, SitecoreDataMappingContext context)
   at Glass.Mapper.Sc.DataMappers.AbstractSitecoreFieldMapper.MapToProperty(AbstractDataMappingContext mappingContext)
   at Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.InterfacePropertyInterceptor.LoadValues()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.InterfacePropertyInterceptor.get_Values()
   at Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.InterfacePropertyInterceptor.Intercept(IInvocation invocation)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Castle.Proxies.IPageBaseProxy.get_TemplateId()
   at ASP._Page_Views_Chrome_cshtml.Execute() in d:\Webroot\Sitecore\Website\Views\Chrome.cshtml:line 11
   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 Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer)

这是错误的代码:

Line 9:      var bodyClass = "";
Line 10: 
Line 11:     if (Model.TemplateId == GlobalId.ArticlePageTemplate.Guid)
Line 12:     {
Line 13:         bodyClass = "pagetype-article";

第 11 行是错误发生的地方。不知道是模型还是我们对静态 ID 的调用。请记住,这是调用我们的编译代码 (DLL) 的第一行代码。如果我删除它,下一个喜欢它的会出错。我已经对页面上的每一行代码进行了测试。

得到了一些额外的信息: 在这种情况下,服务器是由一名 IT 人员重新启动的,因此关闭是正常的和有计划的。所以,我认为负载测试是一个红鲱鱼。尽管我们已经看到在负载测试期间发生了错误,但看起来这种情况可能会在应用程序启动后的第一次请求时随机发生。

4

1 回答 1

4

这是 Glass Mapper 的一个已知问题,已修复:

https://github.com/mikeedwards83/Glass.Mapper/issues/100

您应该更新到最新的 Glass Mapper 版本以摆脱这种情况。

于 2015-03-11T06:46:08.993 回答