From 9ff44fdfbff65a7314d5ab01513e61a5d21c6964 Mon Sep 17 00:00:00 2001 From: Dmitry Dzygin Date: Tue, 6 Mar 2018 16:58:23 +0100 Subject: [PATCH] Fixing an exception during setup if a C1 console for the same website is opened --- Composite/Core/ServiceLocator.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Composite/Core/ServiceLocator.cs b/Composite/Core/ServiceLocator.cs index 654d3a6e47..fa78b53ee9 100644 --- a/Composite/Core/ServiceLocator.cs +++ b/Composite/Core/ServiceLocator.cs @@ -132,7 +132,7 @@ internal static bool HasService(Type serviceType) { Verify.ArgumentNotNull(serviceType, nameof(serviceType)); - if (!SystemSetupFacade.IsSystemFirstTimeInitialized || SystemSetupFacade.SetupIsRunning) + if (ServiceLocatorNotInitialized) { return false; } @@ -221,7 +221,7 @@ internal static void DisposeRequestServicesScope(HttpContext context) internal static IDisposable EnsureThreadDataServiceScope() { - if (RequestScopedServiceProvider != null) return EmptyDisposable.Instance; + if (RequestScopedServiceProvider != null || ServiceLocatorNotInitialized) return EmptyDisposable.Instance; var current = ThreadDataManager.GetCurrentNotNull(); @@ -277,5 +277,7 @@ public void Dispose() } } + private static bool ServiceLocatorNotInitialized => + !SystemSetupFacade.IsSystemFirstTimeInitialized || SystemSetupFacade.SetupIsRunning; } }