严重的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.
原文:
最满意答案
更改
ostream& print(ostream & o);
在你的头文件
uhr.h
中std::ostream& print(std::ostream & o);
change
ostream& print(ostream & o);
in your header file
uhr.h
tostd::ostream& print(std::ostream & o);
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
无处不在使用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 )。 在使用您的程序进行测试时(在我发现 ...
-
C ++ cout操作数错误,类型错误ostream,string [关闭](C++ cout operand error, type error ostream, string [closed])[2024-02-20]
你忘了: #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 ... -
Ostream身份不明?(Ostream unidentified?)[2022-04-17]
我可以在这段代码中看到很多问题:你的运算符<<的声明是使用模板类t,但是没有这个模板类的声明,比如 templateostream& 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);