Error Loading MVC Views

Jan 25, 2013 at 10:41 AM

Hi, 

 

I am experiencing a strange problem with my application. If i "quickly" render and re-render a certain view I get the error below. 

Imagine I have a button that when pressed render a certain view, now to achieve this error i have to click several times in the button and sometimes the answer is the error below.

 

Anyone has the same problem? Any ideas?

 

 

<html>    <head>        <title>Collection was modified; enumeration operation may not execute.</title>            </head>
    <body bgcolor="white">
           

Server Error in '/Glintths.Shell' Application.


           

Collection was modified; enumeration operation may not execute.


           
            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: Collection was modified; enumeration operation may not execute.


            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: Collection was modified; enumeration operation may not execute.]   System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +52   System.Collections.Generic.Enumerator.MoveNextRare() +9365737   System.Collections.Generic.Enumerator.MoveNext() +66   System.Linq.Enumerable.Any(IEnumerable`1 source, Func`2 predicate) +164   System.Web.WebPages.VirtualPathFactoryManager.PageExists(String virtualPath, Boolean useCache) +74   System.Web.WebPages.WebPageRoute.GetRouteLevelMatch(String pathValue, IEnumerable`1 supportedExtensions, VirtualPathFactoryManager virtualPathFactoryManager) +145   System.Web.WebPages.WebPageRoute.MatchRequest(String pathValue, IEnumerable`1 supportedExtensions, VirtualPathFactoryManager virtualPathFactoryManager) +507   System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) +166   System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +91   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

                 

           

           

            Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
           

    </body></html><!-- [InvalidOperationException]: 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.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)   at System.Web.WebPages.VirtualPathFactoryManager.PageExists(String virtualPath, Boolean useCache)   at System.Web.WebPages.WebPageRoute.GetRouteLevelMatch(String pathValue, IEnumerable`1 supportedExtensions, VirtualPathFactoryManager virtualPathFactoryManager)   at System.Web.WebPages.WebPageRoute.MatchRequest(String pathValue, IEnumerable`1 supportedExtensions, VirtualPathFactoryManager virtualPathFactoryManager)   at System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context)   at System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e)   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)--><!-- 

Coordinator
Jan 25, 2013 at 5:44 PM

That looks like a bug in the WebPages runtime. RazorGenerator,Mvc does register a VirtualPathFactory to allow Mvc's runtime to do lookups for Layout pages, but that happens during PreAppStart - much earlier than when PostResolveRequestCache is supposed to be executing. Do you think you could give us a sample app that repros this issue? I can forward it to the WebStack team if it does happen to be an bug in their code.