gpt4 book ai didi

c# - System.Web.Routing.RouteCollection.GetRouteData 中的异常

转载 作者:太空狗 更新时间:2023-10-29 21:07:21 24 4
gpt4 key购买 nike

我在 iis7 上运行的 asp.net mvc 代码中随机出现两个异常:

Exception type: InvalidOperationException 
Exception message: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List'1.Enumerator.MoveNextRare()
at System.Collections.Generic.List'1.Enumerator.MoveNext()
at System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext)
at System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context)
at System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Exception type: NullReferenceException 
Exception message: Object reference not set to an instance of an object.
at System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext)
at System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context)
at System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

它不是始终可重现的,但我认为它正在改变(或破坏)RouteTable.Routes。我在我的项目中访问 RouteTable.Routes 的唯一地方是在 Global.asax.cs 中,我知道那里的代码只被调用一次,所以这不是问题.知道如何追踪它吗?

最佳答案

在我的例子中,它最终成为一个 HttpModule:Ext.Direct.Mvc (用于 ASP.NET MVC 的 Ext.Direct)。该模块有一个错误(已在 0.8.0 版中修复),每次为 IHttpModule 调用 Init() 时都会重新注册路由。 (which might be called multiple times)。如果时机正确,它会破坏 RouteTable.Routes 集合,并导致上述两个异常之一。

关于c# - System.Web.Routing.RouteCollection.GetRouteData 中的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1899188/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com