Recently I was upgrading an Episerver project to v10.9.0 using nuget package manager. I also upgraded the database by entering Update-EPiDatabase -verbose:$true in the nuget package manager console in visual studio.
When trying to run the website I got a http 500 error. In the logs I could see the stacktracke below.
ERROR EPiServer.Framework.Initialization.InitializationEngine: Initialize action failed for 'Initialize on class EPiServer.Enterprise.Internal.EnterpriseInitialization, EPiServer.Enterprise, Version=10.9.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7'
EPiServer.ServiceLocation.ActivationException: Activation error occurred while trying to get instance of type PropertyContentReferenceListTransform, key "" ---> StructureMap.Building.StructureMapBuildException: Error while building type EPiServer.Core.Transfer.Internal.DependentContentTransfer. See the inner exception for details
1.) new DependentContentTransfer(*Default of IContentLoader*, *Default of IContentTypeRepository*, *Default of IPermanentLinkMapper*, *Default of ISiteDefinitionRepository*, *Default of ContentRootService*)
2.) EPiServer.Core.Transfer.Internal.DependentContentTransfer
3.) Instance of EPiServer.Core.Transfer.IDependentContentTransfer (EPiServer.Core.Transfer.Internal.DependentContentTransfer)
4.) new PropertyContentReferenceListTransform(*Default of IPermanentLinkMapper*, *Default of IContentLoader*, *Default of IDependentContentTransfer*)
5.) EPiServer.Core.Transfer.Internal.PropertyContentReferenceListTransform
6.) Instance of EPiServer.Core.Transfer.Internal.PropertyContentReferenceListTransform
7.) Container.GetInstance(EPiServer.Core.Transfer.Internal.PropertyContentReferenceListTransform)
… full stack trace at the end of the post.
The solution
In the connection string the MultipleActiveResultSets=True was missing. Once I added it, the site was working again.
<add name="EPiServerDB" connectionString="Data Source=XXXX;Initial Catalog=XXXX;Integrated Security=False;User ID=XXXX;Password=XXXX;Connect Timeout=30;<strong>MultipleActiveResultSets=True</strong>" providerName="System.Data.SqlClient" /></pre>
The full stacktrace
This is the full stacktrace of the error:
ERROR EPiServer.Framework.Initialization.InitializationEngine: Initialize action failed for 'Initialize on class EPiServer.Enterprise.Internal.EnterpriseInitialization, EPiServer.Enterprise, Version=10.9.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7'
EPiServer.ServiceLocation.ActivationException: Activation error occurred while trying to get instance of type PropertyContentReferenceListTransform, key "" ---> StructureMap.Building.StructureMapBuildException: Error while building type EPiServer.Core.Transfer.Internal.DependentContentTransfer. See the inner exception for details
1.) new DependentContentTransfer(*Default of IContentLoader*, *Default of IContentTypeRepository*, *Default of IPermanentLinkMapper*, *Default of ISiteDefinitionRepository*, *Default of ContentRootService*)
2.) EPiServer.Core.Transfer.Internal.DependentContentTransfer
3.) Instance of EPiServer.Core.Transfer.IDependentContentTransfer (EPiServer.Core.Transfer.Internal.DependentContentTransfer)
4.) new PropertyContentReferenceListTransform(*Default of IPermanentLinkMapper*, *Default of IContentLoader*, *Default of IDependentContentTransfer*)
5.) EPiServer.Core.Transfer.Internal.PropertyContentReferenceListTransform
6.) Instance of EPiServer.Core.Transfer.Internal.PropertyContentReferenceListTransform
7.) Container.GetInstance(EPiServer.Core.Transfer.Internal.PropertyContentReferenceListTransform)
---> System.TypeInitializationException: The type initializer for 'EPiServer.Web.SiteDefinition' threw an exception. ---> System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at EPiServer.DataAccess.Internal.ContentListDB.
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass31_0`1.
at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
at EPiServer.DataAbstraction.Internal.DefaultContentRootRepository.EnsureSystemRoots()
at EPiServer.DataAbstraction.Internal.DefaultContentRootRepository.Load(String rootName)
at EPiServer.Web.SystemDefinition.get_Current()
at EPiServer.Web.SiteDefinition.get_SiteAssetsRoot()
at EPiServer.Web.SiteDefinition.MakeReadOnly()
at EPiServer.Web.SiteDefinition..cctor()
--- End of inner exception stack trace ---
at EPiServer.DataAccess.Internal.SiteDefinitionDB.SiteDefinitionFromReader(IDataRecord r)
at EPiServer.DataAccess.Internal.SiteDefinitionDB.b__4_0()
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass31_0`1.
at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
at EPiServer.Web.Internal.DefaultSiteDefinitionRepository.List()
at EPiServer.Core.Transfer.Internal.DependentContentTransfer..ctor(IContentLoader contentLoader, IContentTypeRepository contentTypeRepository, IPermanentLinkMapper permanentLinkMapper, ISiteDefinitionRepository siteRepository, ContentRootService contentRootService)
at lambda_method(Closure , IBuildSession , IContext )
--- End of inner exception stack trace ---
at lambda_method(Closure , IBuildSession , IContext )
at StructureMap.Building.BuildPlan.Build(IBuildSession session, IContext context) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\Building\BuildPlan.cs:line 151
at StructureMap.SessionCache.GetObject(Type pluginType, Instance instance, ILifecycle lifecycle) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\SessionCache.cs:line 93
at StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\SessionCache.cs:line 68
at StructureMap.Container.GetInstance(Type pluginType) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\Container.cs:line 337
at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
--- End of inner exception stack trace ---
at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()
at EPiServer.Enterprise.Internal.EnterpriseInitialization.RegisterImportingEventHandlers(IDataImportEvents importerEvents, IServiceLocator factory)
at EPiServer.Enterprise.Internal.EnterpriseInitialization.Initialize(InitializationEngine context)
at EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key)
at EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context)
at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()
EPiServer.ServiceLocation.ActivationException: Activation error occurred while trying to get instance of type PropertyContentReferenceListTransform, key "" ---> StructureMap.Building.StructureMapBuildException: Error while building type EPiServer.Core.Transfer.Internal.DependentContentTransfer. See the inner exception for details
1.) new DependentContentTransfer(*Default of IContentLoader*, *Default of IContentTypeRepository*, *Default of IPermanentLinkMapper*, *Default of ISiteDefinitionRepository*, *Default of ContentRootService*)
2.) EPiServer.Core.Transfer.Internal.DependentContentTransfer
3.) Instance of EPiServer.Core.Transfer.IDependentContentTransfer (EPiServer.Core.Transfer.Internal.DependentContentTransfer)
4.) new PropertyContentReferenceListTransform(*Default of IPermanentLinkMapper*, *Default of IContentLoader*, *Default of IDependentContentTransfer*)
5.) EPiServer.Core.Transfer.Internal.PropertyContentReferenceListTransform
6.) Instance of EPiServer.Core.Transfer.Internal.PropertyContentReferenceListTransform
7.) Container.GetInstance(EPiServer.Core.Transfer.Internal.PropertyContentReferenceListTransform)
---> System.TypeInitializationException: The type initializer for 'EPiServer.Web.SiteDefinition' threw an exception. ---> System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at EPiServer.DataAccess.Internal.ContentListDB.
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass31_0`1.
at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
at EPiServer.DataAbstraction.Internal.DefaultContentRootRepository.EnsureSystemRoots()
at EPiServer.DataAbstraction.Internal.DefaultContentRootRepository.Load(String rootName)
at EPiServer.Web.SystemDefinition.get_Current()
at EPiServer.Web.SiteDefinition.get_SiteAssetsRoot()
at EPiServer.Web.SiteDefinition.MakeReadOnly()
at EPiServer.Web.SiteDefinition..cctor()
--- End of inner exception stack trace ---
at EPiServer.DataAccess.Internal.SiteDefinitionDB.SiteDefinitionFromReader(IDataRecord r)
at EPiServer.DataAccess.Internal.SiteDefinitionDB.b__4_0()
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass31_0`1.
at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
at EPiServer.Web.Internal.DefaultSiteDefinitionRepository.List()
at EPiServer.Core.Transfer.Internal.DependentContentTransfer..ctor(IContentLoader contentLoader, IContentTypeRepository contentTypeRepository, IPermanentLinkMapper permanentLinkMapper, ISiteDefinitionRepository siteRepository, ContentRootService contentRootService)
at lambda_method(Closure , IBuildSession , IContext )
--- End of inner exception stack trace ---
at lambda_method(Closure , IBuildSession , IContext )
at StructureMap.Building.BuildPlan.Build(IBuildSession session, IContext context) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\Building\BuildPlan.cs:line 151
at StructureMap.SessionCache.GetObject(Type pluginType, Instance instance, ILifecycle lifecycle) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\SessionCache.cs:line 93
at StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\SessionCache.cs:line 68
at StructureMap.Container.GetInstance(Type pluginType) in c:\BuildAgent\work\a395dbde6b793293\src\StructureMap\Container.cs:line 337
at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
--- End of inner exception stack trace ---
at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()
at EPiServer.Enterprise.Internal.EnterpriseInitialization.RegisterImportingEventHandlers(IDataImportEvents importerEvents, IServiceLocator factory)
at EPiServer.Enterprise.Internal.EnterpriseInitialization.Initialize(InitializationEngine context)
at EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key)
at EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context)
at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()