在System.Web.Routing.RouteCollection.GetRouteData例外 [英] Exceptions in System.Web.Routing.RouteCollection.GetRouteData

查看:894
本文介绍了在System.Web.Routing.RouteCollection.GetRouteData例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到随机时间两个例外在我的asp.net mvc的code IIS7上运行:

I've been getting two exceptions at random times in my asp.net mvc code running on iis7:

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 ,我知道,code可能会只被调用一次,所以这不是问题。如何追查任何想法?

It's not consistently reproducible, but I assume it's something changing (or corrupting) RouteTable.Routes. The only place I access RouteTable.Routes in my project is in Global.asax.cs and I know that the code there is only being called once, so it's not the problem. Any idea on how to track it down?

推荐答案

在我的情况下,它结束了是一个的HttpModule:的 Ext.Direct.Mvc (Ext.Direct的ASP.NET MVC)。该模块有其重新注册的路线每次初始化()被调用的IHttpModule的错误(在0.8.0版修复)。 (可能被多次调用的)。如果时机是正确的,它会破坏 RouteTable.Routes 收集,并导致上述两个例外之一。

In my case, it ended up being a HttpModule: Ext.Direct.Mvc (Ext.Direct for ASP.NET MVC). This module had a bug (Fixed in version 0.8.0) which registered routes again every time Init() was called for the IHttpModule. (which might be called multiple times). If the timing was right, it would corrupt the RouteTable.Routes collection, and cause one of the two exceptions above.

这篇关于在System.Web.Routing.RouteCollection.GetRouteData例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆