首页 \ 问答 \ 严重的Sitecore MVC / Glassmapper问题(Serious Sitecore MVC/Glassmapper issue)

严重的Sitecore MVC / Glassmapper问题(Serious Sitecore MVC/Glassmapper issue)

我们为客户端提供Sitecore站点,该站点抛出了与MVC和/或Glassmapper相关的错误。 在负载测试期间(不是大量)负载下,它发生在内容传送服务器上。 它似乎发生在网站首次编译时。 在此事件发生之前,我们关闭了sitecore(“HostingEnvironment started shutdown”),当它重新启动时,在主视图中遇到的第一行代码会引发错误。 如果我删除该行,那么错误后的行等等,一直向下移动页面。 好像没有代码可以运行,就像重新启动时某些东西会被破坏一样。 如果我重置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人员重新启动,因此关闭是正常的并且是计划好的。 所以,我认为负载测试是一个红色的鲱鱼。 即使我们已经看到在负载测试期间发生错误,看起来这种情况可能会在应用程序启动后的第一个请求中随机发生。


We have a Sitecore site for a client that is throwing an error that seems related to MVC and/or Glassmapper. It happening on the content delivery server when under some load during load testing (not massive). It appears to happen when the site is first compiling. Prior to this event, we get a sitecore shut down ("HostingEnvironment initiated shutdown"), When it restarts the first line of code that's hit in the main view throws an error. If I remove that line, then the line after errors, etc., all the way down the page. It's as if no code can run, like the something become corrupt when it restarted. If I reset IIS the issue goes away. All of our code is complied in the DLLs, except the Razor views, of course.

I know this is all a big vauge, but if anyone has experienced an issue like this or has any ideas where to look, it would be greatly appreciated!

Here's the stack trace:

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)

Here's the code that errors:

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

Line 11 is where the error occurs. Don't know if it's the Model that's or our call to the static ID. Keep in mind that this is the very first line of code that calls out to our compiled code (DLL). If I remove it, the next one like it will error. I've tested this for every line of code on the page.

Got some additional information: The server was restarted by an IT guy in this case, so the shutdown was normal and planned. So, I think the load testing is a red herring. Even though we've seen the error happen during load testing, it looks like this situation can happen randomly on first request after the app starts.


原文:
更新时间:2022-12-20 16:12

最满意答案

更改

ostream& print(ostream & o);

在你的头文件uhr.h

std::ostream& print(std::ostream & o);

change

ostream& print(ostream & o);

in your header file uhr.h to

std::ostream& print(std::ostream & o);

相关问答

更多
  • 无处不在使用std::ostream和std::istream 。 ostream和istream在命名空间std Use std::ostream and std::istream everywhere. ostream and istream are in namespace std
  • Boost的asio库在streambuffers级别上与std iostream集成 所以写一个请求 boost::asio::streambuf request; std::ostream request_stream(&request); request_stream << "GET " << argv[2] << " HTTP/1.0\r\n"; request_stream << "Host: " << argv[1] << "\r\n"; request_stream << "Accept: * ...
  • 代码中有许多错误。 你大量使用using namespace std 。 这是一个不好的做法 。 尤其是,这导致了你面临的错误:你没有在Dollar.h using namespace std ,因此编译器不知道ostream含义。 要么在Dollar.h using namespace std ,要么停止使用它,并直接指定std名称空间,就像在std::ostream 。 在头文件中使用std::ostream ,但不在其中包含相应的标准库头包含std::ostr ...
  • 问题似乎是你的对象d在std::cout之前被销毁,因此最终调用了破坏全局对象,包括刷新缓冲区,并且在main()结束后占据了一个位置(记住它是一个全局对象),尝试对不再存在的streambuf对象执行操作。 您的缓冲区对象肯定应该比您关联的流更长。 在你的程序中有这个的一种方法是将d变成一个你永远不会删除的指针。 或者,您可以在使用它时保留本地对象,但调用std::cout.flush() ,然后在超出范围之前将cout的缓冲区分配给其他东西(甚至是nullptr )。 在使用您的程序进行测试时(在我发现 ...
  • 你忘了: #include 您不应该通过包含其他标头间接地依赖相关标准标头。 此外,将main()的签名更改为合法签名,例如: int main() { // ... } You forgot to: #include You should never rely on relevant standard headers to be included indirectly through the inclusion of other headers. Also ...
  • 我可以在这段代码中看到很多问题:你的运算符<<的声明是使用模板类t,但是没有这个模板类的声明,比如 template ostream& operator<< (ostream &out, List const* p); 在第二个参数中,这些函数的声明和定义也不相等: ostream& operator<< (ostream &out, List const* p); ostream& operator<< (ostream &out, ListNode::List const ...
  • 您在Device类中声明的内容是 friend ostream& operator<<(ostream& os, const Device& v); 但你提供的实现是什么 ostream& operator<<(ostream& out, Device& v) { out << "Device " << v.get_name() << " Has an ID of: " << v.get_id(); return out; } 这不是一回事 ! 你告诉编译器有一个friend函数,它引用 ...
  • 更改 ostream& print(ostream & o); 在你的头文件uhr.h中 std::ostream& print(std::ostream & o); change ostream& print(ostream & o); in your header file uhr.h to std::ostream& print(std::ostream & o);

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)