U4-9097 - IServerRegistrationService missing form ServiceContext constructor

Created by Lucas Wolkowski 23 Oct 2016, 15:49:58 Updated by Shane Marsden 03 Nov 2016, 12:42:50

Tags: PR

ServiceContext constructor that takes various umbraco Service implementaitons is missing IServerRegistrationService on the list of parameters. Trying to override ServiceContext with custom service context and use this constructor will produce error in ServerRegistrationEventHandler

Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 378: public IServerRegistrationService ServerRegistrationService Line 379: { Line 380: get { return _serverRegistrationService.Value; } Line 381: } Line 382:

[NullReferenceException: Object reference not set to an instance of an object.] Umbraco.Core.Services.ServiceContext.get_ServerRegistrationService() in D:\ProjectTemp\Umb7.5.4\Umbraco-CMS-release-7.5.4\src\Umbraco.Core\Services\ServiceContext.cs:380 Umbraco.Web.Strategies.<>c__DisplayClass7_0.b__0() in D:\ProjectTemp\Umb7.5.4\Umbraco-CMS-release-7.5.4\src\Umbraco.Web\Strategies\ServerRegistrationEventHandler.cs:81 System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func1 valueFactory) +136 Umbraco.Web.Strategies.ServerRegistrationEventHandler.RegisterBackgroundTasks(UmbracoRequestEventArgs e) in D:\ProjectTemp\Umb7.5.4\Umbraco-CMS-release-7.5.4\src\Umbraco.Web\Strategies\ServerRegistrationEventHandler.cs:78 Umbraco.Web.Strategies.ServerRegistrationEventHandler.UmbracoModuleRouteAttempt(Object sender, RoutableAttemptEventArgs e) in D:\ProjectTemp\Umb7.5.4\Umbraco-CMS-release-7.5.4\src\Umbraco.Web\Strategies\ServerRegistrationEventHandler.cs:67 System.EventHandler1.Invoke(Object sender, TEventArgs e) +0 Umbraco.Web.UmbracoModule.OnRouteAttempt(RoutableAttemptEventArgs args) in D:\ProjectTemp\Umb7.5.4\Umbraco-CMS-release-7.5.4\src\Umbraco.Web\UmbracoModule.cs:546 Umbraco.Web.UmbracoModule.ProcessRequest(HttpContextBase httpContext) in D:\ProjectTemp\Umb7.5.4\Umbraco-CMS-release-7.5.4\src\Umbraco.Web\UmbracoModule.cs:117 Umbraco.Web.UmbracoModule.b__12_3(Object sender, EventArgs e) in D:\ProjectTemp\Umb7.5.4\Umbraco-CMS-release-7.5.4\src\Umbraco.Web\UmbracoModule.cs:515 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +91 }

Constructor should assign all Umbraco Services to avoid this problem.

Comments

Shane Marsden 03 Nov 2016, 12:42:50

PR: https://github.com/umbraco/Umbraco-CMS/pull/1578


Priority: Normal

Type: Bug

State: Submitted

Assignee:

Difficulty: Very Easy

Category: Extensibility

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.5.4

Due in version:

Sprint:

Story Points:

Cycle: