November Happy Hour will be moved to Thursday December 5th.

Episerver initialization fails with message - Sequence contains no elements

Vote:
 

Hi All, 

This is a problem that's happened for the second time in our project now. We suddenly get this error in episerver. (episerver cms 11.13.2 with commerce)
Last time we fixed this by reverting the CMS database to an earlier version (in Azure). But I would like to know what couses this.

Any sugestions?

Server Error in '/' Application.

Sequence contains no elements

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: Sequence contains no elements

Source Error:

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

  <%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:

<configuration>
   <system.web>
       <compilation debug="true"/>
   </system.web>
</configuration>

Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.


Stack Trace:

[InvalidOperationException: Sequence contains no elements]
   System.Linq.Enumerable.First(IEnumerable`1 source) +455
   EPiServer.Marketing.Testing.Dal.BaseRepository.GetDatabaseVersion(String contextKey) +541
   EPiServer.Marketing.Testing.Dal.DataAccess.TestingDataAccess.GetDatabaseVersionHelper(IRepository repo, String contextKey) +29
   EPiServer.Marketing.Testing.Dal.DataAccess.TestingDataAccess.GetDatabaseVersion(DbConnection dbConnection, String schema, String contextKey) +126
   EPiServer.Marketing.Testing.Dal.DataAccess.TestingDataAccess..ctor() +212
   EPiServer.Marketing.Testing.Core.Manager.TestManager..ctor() +303
   lambda_method(Closure , IBuildSession , IContext ) +181

[StructureMapBuildException: Error while building type EPiServer.Marketing.Testing.Core.Manager.TestManager.  See the inner exception for details
1.) new TestManager()
2.) EPiServer.Marketing.Testing.Core.Manager.TestManager
3.) Instance of EPiServer.Marketing.Testing.Core.Manager.ITestManager (EPiServer.Marketing.Testing.Core.Manager.TestManager)
4.) Container.GetInstance(EPiServer.Marketing.Testing.Core.Manager.ITestManager)
5.) Container.TryGetInstance(EPiServer.Marketing.Testing.Core.Manager.ITestManager)
]
   lambda_method(Closure , IBuildSession , IContext ) +1084
   StructureMap.Building.BuildPlan.Build(IBuildSession session, IContext context) +145
   System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +76
   StructureMap.SessionCache.GetObject(Type pluginType, Instance instance, ILifecycle lifecycle) +217
   StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph) +191
   StructureMap.Container.GetInstance(Type pluginType) +401
   StructureMap.Container.TryGetInstance(Type pluginType) +184
   EPiServer.ServiceLocation.StructureMapServiceLocator.DoTryGetExistingInstance(Type serviceType, String key, Object& instance) +53
   EPiServer.ServiceLocation.ServiceLocatorExtensions.TryGetExistingInstance(IServiceLocator serviceLocator, TService& instance) +75
   EPiServer.Marketing.Testing.Web.SchemaUpdater.DatabaseVersionValidator.GetStatus(ConnectionStringsSection connectionStrings) +105
   EPiServer.Data.SchemaUpdates.Internal.SchemaUpdaterWrapper.GetStatus(IEnumerable`1 ConnectionStringOptions) +46
   EPiServer.Data.SchemaUpdates.Internal.<>c__DisplayClass6_0.<EnsureDatabaseSchema>b__0(ISchemaUpdater u) +60
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +241
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +526
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +69
   EPiServer.Data.SchemaUpdates.Internal.DatabaseSchemaManagerImplementation.EnsureDatabaseSchema(DataAccessOptions dataAccessOptions) +193
   EPiServer.Data.DataInitialization.Initialize(InitializationEngine context) +31
   EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key) +58
   EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context) +123
   EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +257

[InitializationException: Initialize action failed for Initialize on class EPiServer.Data.DataInitialization, EPiServer.Data, Version=11.13.2.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7]
   EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +786
   EPiServer.Framework.Initialization.InitializationEngine.ExecuteTransition(Boolean continueTransitions) +194
   EPiServer.Framework.Initialization.InitializationModule.EngineExecute(HostType hostType, Action`1 engineAction) +879
   EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType) +226
   EPiServer.Global..ctor() +42
   Ahrend.Web.EPiServerApplication..ctor() +37
   ASP.global_asax..ctor() +42

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +142
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +107
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1476
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +186
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +80
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +182
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +724


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

#224768
Jun 25, 2020 13:40
Vote:
 

Has anyone seen this happen before?  We just ran into this problem again and I would like to know why this is happening.

#225794
Jul 27, 2020 6:55
Vote:
 

Comparing this error version to a working database the problem seems to be in the MigrationHistory table.

The Marketing package tries to load the database version by looking in the __MigrationHistory table, searching for records with the contextKey "Testing.Migrations.Configuration" but no records exist with this key in the error database. Only entries with the ContextKey 'DbLocalizationProvider.LanguageEntities' remain.

What could possibly result in the removal of the other records in this table?

#225795
Jul 27, 2020 7:15
Vote:
 

We are running into the same problem, out of the blue. It worked before the weekend and not working with A/B testing for a while.

Using episerver framework/CMS 11.15.1


                        
#278313
Apr 11, 2022 9:32
Vote:
 

I have no idea what might have caused this, but the workaround seems to be running the sql in EPiServer.Marketing.Testing.2.6.10\tools\epiupdates\sql

you probably just need to run the latest file (1.0.0.8.sql) 

#278366
Apr 12, 2022 6:35
Vote:
 

Whoa! Seeing tables and indexes having been created, the MigrationTable has no records of Marketing-stuff. 
Looked into test database and comparing to the development database seeing multiple occurences so somehow the migration history in the development databas seems to be emptied.

Thanks for the push in the right direction.

So the marketing tables and indexes seems to be in place but not the migration table rows. 
Is this the issue, you think?

Just running 1.0.0.8.sql did not cut it.

#278367
Apr 12, 2022 7:16
Vote:
 

Turns out the rows in Migration table is there but in ContextKey 'DbLocalizationProvider.LanguageEntities' instead. 
Is Valdis to blame here?   ;) 

Anyhow. Having ensured that allt changes is in place and Migration History includes all 8 rows, I am getting the same error.

[InvalidOperationException: Sekvensen innehåller inga element]
   System.Linq.Enumerable.First(IEnumerable`1 source) +455
   EPiServer.Marketing.KPI.Dal.BaseRepository.GetDatabaseVersion(String contextKey) +541
   EPiServer.Marketing.KPI.DataAccess.KpiDataAccess.GetDatabaseVersionHelper(IRepository repo, String contextKey) +35
   EPiServer.Marketing.KPI.DataAccess.KpiDataAccess.GetDatabaseVersion(DbConnection dbConnection, String schema, String contextKey) +126
   EPiServer.Marketing.KPI.SchemaUpdater.DatabaseVersionValidator.GetStatus(IEnumerable`1 connectionStringOptions) +178
   EPiServer.Data.SchemaUpdates.Internal.<>c__DisplayClass6_0.<EnsureDatabaseSchema>b__0(ISchemaUpdater u) +66
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +241
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +526
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +69
   EPiServer.Data.SchemaUpdates.Internal.DatabaseSchemaManagerImplementation.EnsureDatabaseSchema(DataAccessOptions dataAccessOptions) +193
   EPiServer.Data.DataInitialization.Initialize(InitializationEngine context) +31
   EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key) +58
   EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context) +123
   EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +275

[InitializationException: Initialize action failed for Initialize on class EPiServer.Data.DataInitialization, EPiServer.Data, Version=11.15.1.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7]
   EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +836
   EPiServer.Framework.Initialization.InitializationEngine.ExecuteTransition(Boolean continueTransitions) +194
   EPiServer.Framework.Initialization.InitializationModule.EngineExecute(HostType hostType, Action`1 engineAction) +885
   EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType) +226
   EPiServer.Global..ctor() +42
   Mau.Epi.EPiServerApplication..ctor() in C:\Users\myuser\source\repos\Site.Epi\Site\Site.Epi\Global.asax.cs:13
   ASP.global_asax..ctor() +48

Edit: I found another row that was not set in Migration table.  Fixing this made the site working again
201604051658334_Initial    KPI.Migrations.Configuration

#278368
Edited, Apr 12, 2022 7:31
valdis - Apr 27, 2022 20:07
I have nothing to do with this :D
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.