Maybe it's a bug?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
It's not a bug.... but...

I have a test nopcommerce store 4.20 with many plugins (120).
When I pressed the button "restart store" and after 2-3 second I open another page in the new window and try to open this test nop store I saw such error message.
I understand that nop didn't started yet.
When nop store started than I can open any page without any error messages.

The problem is in this code

                widgets = widgets.Where(widget =>
                    widget.GetWidgetZones().Contains(widgetZone, StringComparer.InvariantCultureIgnoreCase)).ToList();


Collection was modified; enumeration operation may not execute.
Full message
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Linq.Enumerable.Contains[TSource](IEnumerable`1 source, TSource value, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.WhereListIterator`1.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Nop.Services.Cms.WidgetPluginManager.LoadActivePlugins(Customer customer, Int32 storeId, String widgetZone)
   at Nop.Web.Areas.Admin.Factories.WidgetModelFactory.PrepareRenderWidgetModels(String widgetZone, Object additionalData)
   at Nop.Web.Areas.Admin.Components.AdminWidgetViewComponent.Invoke(String widgetZone, Object additionalData)
   at lambda_method(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeSyncCore(ObjectMethodExecutor executor, ViewComponentContext context)
3 years ago
We've had same error. Any solution for this?
3 years ago
No
3 years ago
Maybe this is related here
3 years ago
This is error we're receiving

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Linq.Enumerable.Contains[TSource](IEnumerable`1 source, TSource value, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.WhereListIterator`1.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Nop.Services.Cms.WidgetPluginManager.LoadActivePlugins(Customer customer, Int32 storeId, String widgetZone) in C:\Files\projects\portlandcompressor\src\Libraries\Nop.Services\Cms\WidgetPluginManager.cs:line 47
   at Nop.Web.Factories.WidgetModelFactory.<>c__DisplayClass6_0.<PrepareRenderWidgetModel>b__0() in C:\Files\projects\portlandcompressor\src\Presentation\Nop.Web\Factories\WidgetModelFactory.cs:line 59
   at EasyCaching.InMemory.DefaultInMemoryCachingProvider.BaseGet[T](String cacheKey, Func`1 dataRetriever, TimeSpan expiration)
   at EasyCaching.Core.EasyCachingAbstractProvider.Get[T](String cacheKey, Func`1 dataRetriever, TimeSpan expiration)
   at Nop.Core.Caching.MemoryCacheManager.Get[T](String key, Func`1 acquire, Nullable`1 cacheTime) in C:\Files\projects\portlandcompressor\src\Libraries\Nop.Core\Caching\MemoryCacheManager.cs:line 42
   at Nop.Web.Factories.WidgetModelFactory.PrepareRenderWidgetModel(String widgetZone, Object additionalData) in C:\Files\projects\portlandcompressor\src\Presentation\Nop.Web\Factories\WidgetModelFactory.cs:line 58
   at Nop.Web.Components.WidgetViewComponent.Invoke(String widgetZone, Object additionalData) in C:\Files\projects\portlandcompressor\src\Presentation\Nop.Web\Components\Widget.cs:line 19
   at lambda_method(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeSyncCore(ObjectMethodExecutor executor, ViewComponentContext context)
   at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeAsync(ViewComponentContext context)
   at StackExchange.Profiling.Internal.ProfilingViewComponentInvoker.InvokeAsync(ViewComponentContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore.Mvc\Internal\ProfilingViewComponentInvoker.cs:line 30
   at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentHelper.InvokeCoreAsync(ViewComponentDescriptor descriptor, Object arguments)
   at AspNetCore.Themes_Wind_Views_Shared__Root.ExecuteAsync() in C:\inetpub\portlandcompressor.com\Themes\Wind\Views\Shared\_Root.cshtml:line 15
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
   at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsync[TFilter,TFilterAsync]()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultFilters()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at WebMarkupMin.AspNetCore2.WebMarkupMinMiddleware.Invoke(HttpContext context)
   at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 94
   at Nop.Services.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) in C:\Files\projects\portlandcompressor\src\Libraries\Nop.Services\Authentication\AuthenticationMiddleware.cs:line 79
   at FoxNetSoft.Plugin.Misc.RedirectManager.Infrastructure.PageManagerMiddleware.Invoke(HttpContext context, IWebHelper webHelper, IWorkContext workContext, IStoreContext storeContext, RedirectManagerSettings redirectManagerSettings)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Nop.Services.Installation.InstallUrlMiddleware.Invoke(HttpContext context, IWebHelper webHelper) in C:\Files\projects\portlandcompressor\src\Libraries\Nop.Services\Installation\InstallUrlMiddleware.cs:line 52
   at Nop.Services.Common.KeepAliveMiddleware.Invoke(HttpContext context, IWebHelper webHelper) in C:\Files\projects\portlandcompressor\src\Libraries\Nop.Services\Common\KeepAliveMiddleware.cs:line 49
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
3 years ago
I have a test store with more 120 plugins.
I see this error message from time to time when nopcommerce starts.
I investigated this issue but I didn't find the reason.
3 years ago
We also investigated this problem from our side. We did not find any errors, probably the problem is in the implementation of the GetWidgetZones() method in the third party plugins. Please check this if possible.
3 years ago
I found the several reasons of this issue.
1. customer used Smarterasp.net and Smarterasp.net has a memory limits.
we increased the memory limit and we forgot about this issue.
2. another customer used antivirus and add the site folder in it...
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.