asp.Net   发布时间:2022-04-07  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了asp.net-mvc-3 – _AppStart正在执行时无法创建存储范围大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
使用ASP.NET MVC 3.0与Visual studio 2010(SP1之前和SP1)和ASP.NET开发服务器我得到错误“_AppStart正在执行时无法创建存储范围”。每次我调试当我等待几秒钟,并刷新浏览器它按预期工作。

这是否发生在每个人身上?
有没有办法来预防?
我应该在生产中担心吗? (IIS 6/7主机)

相关work-item #7828 on codeplex没有正式的回复。

全堆栈跟踪:

Server Error in '/' Application.
--------------------------------------------------------------------------------
Storage scopes cAnnot be created when _AppStart is execuTing. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidoperationException: Storage scopes cAnnot be created when _AppStart is execuTing.

source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and LOCATIOn of the exception can be identified using the exception stack trace below.  

Stack Trace: 
[InvalidoperationException: Storage scopes cAnnot be created when _AppStart is execuTing.]
   System.Web.WebPages.Scope.AspNetrequestScopeStorageProvider.set_CurrentScope(IDictionary`2 value) +83361
   System.Web.WebPages.Scope.ScopeStorage.CreateTransientScope(IDictionary`2 context) +95
   System.Web.WebPages.Scope.ScopeStorage.CreateTransientScope() +76
   System.Web.Mvc.ControllerBase.Execute(requestContext requestContext) +84
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(requestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessrequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessrequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessrequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IhttpAsyncHandler.EndProcessrequest(IAsyncResult result) +9
   System.Web.CallHandlerEXECUTIONStep.System.Web.httpApplication.IEXECUTIONStep.Execute() +8862381
   System.Web.httpApplication.ExecuteStep(IEXECUTIONStep step,Boolean& completedSynchronously) +184

解决方法

然我不知道为什么会发生这种情况(我也不能重现这一点)我可能会有一些修复,你可以尝试。 WebPagehttpR_628_11845@odule(在system.Web.WebPages中)应该设置为AppStartExecuteCompleted,但它不会,这就是为什么你得到一个异常(所有这些猜测工作是基于此)。

所以…看看源代码我相信这个bug的根源是Web开发服务器和PreApplicationCode动态注册一个模块(WebPagehttpR_628_11845@odulE)的东西。模块init应该始终运行在应用程序开始,但由于某种原因我GUESS它没有。也许有人可以以某种方式测试它。

一些我想到的修复(再次,这是纯粹的猜测工作,因为我无法重现)。

1)尝试在WebConfig中静态注册WebPagehttpR_628_11845@odule模块。更新我已经测试了这个,这不会抛出异常。但是,它注册了两个httpR_628_11845@odules。

2)根据对你链接的线程的评论,似乎这不会发生在IIS上,所以我试图运行在IIS Express(在VS 2010 SP1下)。

正如我之前所说,这只是猜测工作。模块不能运行可能有其他原因…如Web服务器未正确重新启动,包括PreApplicationCode中的一些问题,或者不将httpR_628_11845@odule中的s_appStartExecutedLock重置为false,或者与httpContext.Items相关的内容可能还有导致模块不能运行…

大佬总结

以上是大佬教程为你收集整理的asp.net-mvc-3 – _AppStart正在执行时无法创建存储范围全部内容,希望文章能够帮你解决asp.net-mvc-3 – _AppStart正在执行时无法创建存储范围所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。