Piotr Stapp
Piotr Stapp

Reputation: 19830

Strange exception in MVC

Very very rare my MVC 3 application have following exception. It is only in Release mode, and when it starts only restart of IIS application pool helps. Does anyone could give me a tip what can cause this error?

And the exception:

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Web.Mvc.FilterProviderCollection.<RemoveDuplicates>d__b.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.<ReverseIterator>d__a0`1.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at System.Web.Mvc.FilterInfo..ctor(IEnumerable`1 filters)
   at System.Web.Mvc.ControllerActionInvoker.GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Upvotes: 5

Views: 801

Answers (1)

Scooletz
Scooletz

Reputation: 183

It looks like you modify the GlobalFilters collection without lock. It may happen when you access this collection for instance from IHttpModule.Init, which is called for each HttpApplication created by the runtime. Had this problem once.

Use WebActivator or simply Global_asax App_Start to init this kind of global collections.

Upvotes: 1

Related Questions