收集被修改;枚举操作可能无法执行

时间:2015-09-18 06:12:03

标签: asp.net runtime-error cultureinfo

我的asp.net网站抛出此异常"收集已修改;枚举操作可能无法执行" sometime.Stack Trace告诉我这个错误来自于改变语言功能。这是改变语言的代码。

protected override void ExecuteCore()
    {
        string cultureName = UserSession.Current.Language;
        if (string.IsNullOrEmpty(cultureName))
        {
            cultureName = "en-US"; // default
            UserSession.Current.Language = cultureName;
        }

        // Modify current thread's cultures
        Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureName);
        Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

        System.Globalization.CultureInfo def = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

        System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat = def.DateTimeFormat;
        System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat = def.NumberFormat;

        base.ExecuteCore();
    }

但是我不能在LOCAL或Visual studio上重新制作它,它只在Production上随机发生。

这是我从调试工具获得的完整堆栈跟踪。

   KERNELBASE!RaiseException+39 
clr!ClrCreateManagedInstance+5984d 
clr!CompareAssemblyIdentityWithConfig+787b 
clr!CreateAssemblyConfigCookie+e03c6 
[[HelperMethodFrame_PROTECTOBJ] (System.Reflection.RuntimeAssembly._nLoad)] System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMarkByRef, Boolean, Boolean, Boolean) 
mscorlib_ni!System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(System.String, System.Globalization.CultureInfo, System.Version, Boolean, System.Threading.StackCrawlMark ByRef)+ee 
mscorlib_ni!System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(System.Globalization.CultureInfo, System.Threading.StackCrawlMark ByRef)+d7 
mscorlib_ni!System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(System.Globalization.CultureInfo, System.Collections.Generic.Dictionary`2<System.String,System.Resources.ResourceSet>, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)+e2 
mscorlib_ni!System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)+268 
mscorlib_ni!System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo, Boolean, Boolean)+23 
mscorlib_ni!System.Resources.ResourceManager.GetString(System.String, System.Globalization.CultureInfo)+13c 
System_Web_Mvc_ni!System.Web.Mvc.ClientDataTypeModelValidatorProvider+NumericModelValidator..ctor(System.Web.Mvc.ModelMetadata, System.Web.Mvc.ControllerContext)+71 
System_Web_Mvc_ni!System.Web.Mvc.ClientDataTypeModelValidatorProvider+<GetValidatorsImpl>d__0.MoveNext()+151 
System_Core_ni!System.Linq.Enumerable+<SelectManyIterator>d__14`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].MoveNext()+1fb 
System_Web_Mvc_ni!System.Web.Mvc.ModelValidator+CompositeModelValidator+<Validate>d__1.MoveNext()+30b 
System_Web_Mvc_ni!System.Web.Mvc.DefaultModelBinder.OnModelUpdated(System.Web.Mvc.ControllerContext, System.Web.Mvc.ModelBindingContext)+1b8 
System_Web_Mvc_ni!System.Web.Mvc.DefaultModelBinder.BindComplexModel(System.Web.Mvc.ControllerContext, System.Web.Mvc.ModelBindingContext)+2ba 
System_Web_Mvc_ni!System.Web.Mvc.ControllerActionInvoker.GetParameterValue(System.Web.Mvc.ControllerContext, System.Web.Mvc.ParameterDescriptor)+1e9 
System_Web_Mvc_ni!System.Web.Mvc.ControllerActionInvoker.GetParameterValues(System.Web.Mvc.ControllerContext, System.Web.Mvc.ActionDescriptor)+98 
System_Web_Mvc_ni!System.Web.Mvc.ControllerActionInvoker.InvokeAction(System.Web.Mvc.ControllerContext, System.String)+139 
System_Web_Mvc_ni!System.Web.Mvc.Controller.ExecuteCore()+9f 
Fanex.Razorbill.Module.Core.Web.Controllers.BaseController.ExecuteCore()+2a4 
System_Web_Mvc_ni!System.Web.Mvc.ControllerBase.Execute(System.Web.Routing.RequestContext)+14f 
System_Web_Mvc_ni!System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass1.<MakeVoidDelegate>b__0()+14 
System_Web_Mvc_ni!System.Web.Mvc.Controller.EndExecute(System.IAsyncResult)+35 
System_Web_Mvc_ni!System.Web.Mvc.MvcHandler+<>c__DisplayClass8.<BeginProcessRequest>b__3(System.IAsyncResult)+2a 
System_Web_Mvc_ni!System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass4.<MakeVoidDelegate>b__3(System.IAsyncResult)+14 
System_Web_Mvc_ni!System.Web.Mvc.MvcHandler.EndProcessRequest(System.IAsyncResult)+35 
System_Web_ni!System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+1d5 
System_Web_ni!System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)+177 
System_Web_ni!System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)+6f5 
System_Web_ni!System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)+85 
System_Web_ni!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)+2b6 
System_Web_ni!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+3bf 
System_Web_ni!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+22 
System_Web_ni!DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+51 
clr!ClrCreateManagedInstance+2f2c7 
webengine4!W3_MGD_HANDLER::ProcessNotification+79 
webengine4!W3_MGD_HANDLER::DoWork+310 
webengine4!RequestDoWork+42d 
webengine4!CMgdEngHttpModule::OnExecuteRequestHandler+24 
iiscore!NOTIFICATION_CONTEXT::RequestDoWork+233 
iiscore!NOTIFICATION_CONTEXT::CallModulesInternal+174 
iiscore!NOTIFICATION_CONTEXT::CallModules+25 
iiscore!W3_CONTEXT::DoWork+34d 
iiscore!W3_CONTEXT::IndicateCompletion+8c 
webengine4!W3_MGD_HANDLER::IndicateCompletion+59 
webengine4!MgdIndicateCompletion+22 
clr+17c7 
System_Web_ni!DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)+57 
[[NDirectMethodFrameStandalone] (System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion)] System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatusByRef) 
System_Web_ni!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+4f4 
System_Web_ni!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+22 
System_Web_ni!DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+51 
clr!ClrCreateManagedInstance+2f52b 
clr!CopyPDBs+2223 
clr!CoInitializeEE+5c7f 
[[ContextTransitionFrame]] 
clr!CopyPDBs+2176 
clr!ClrCreateManagedInstance+2f4c3 
webengine4!W3_MGD_HANDLER::ProcessNotification+79 
webengine4!ProcessNotificationCallback+43 
clr!ClrCreateManagedInstance+29dc5 
clr!ClrCreateManagedInstance+29308 
clr!ClrCreateManagedInstance+4d02b 
clr!ClrCreateManagedInstance+4b3a6 
kernel32!BaseThreadInitThunk+d 
ntdll!RtlUserThreadStart+1d

0 个答案:

没有答案