{"action":"created","issue":{"url":"https://api.github.com/repos/umbraco/Umbraco-CMS/issues/3707","repository_url":"https://api.github.com/repos/umbraco/Umbraco-CMS","labels_url":"https://api.github.com/repos/umbraco/Umbraco-CMS/issues/3707/labels{/name}","comments_url":"https://api.github.com/repos/umbraco/Umbraco-CMS/issues/3707/comments","events_url":"https://api.github.com/repos/umbraco/Umbraco-CMS/issues/3707/events","html_url":"https://github.com/umbraco/Umbraco-CMS/issues/3707","id":382006728,"node_id":"MDU6SXNzdWUzODIwMDY3Mjg=","number":3707,"title":"[v8] Can't start CoreRuntime on its own","user":{"login":"aaronpowell","id":434140,"node_id":"MDQ6VXNlcjQzNDE0MA==","avatar_url":"https://avatars0.githubusercontent.com/u/434140?v=4","gravatar_id":"","url":"https://api.github.com/users/aaronpowell","html_url":"https://github.com/aaronpowell","followers_url":"https://api.github.com/users/aaronpowell/followers","following_url":"https://api.github.com/users/aaronpowell/following{/other_user}","gists_url":"https://api.github.com/users/aaronpowell/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronpowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronpowell/subscriptions","organizations_url":"https://api.github.com/users/aaronpowell/orgs","repos_url":"https://api.github.com/users/aaronpowell/repos","events_url":"https://api.github.com/users/aaronpowell/events{/privacy}","received_events_url":"https://api.github.com/users/aaronpowell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-11-18T22:19:22Z","updated_at":"2018-11-21T04:40:04Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I'm starting to look into getting [Chauffeur](https://aaronpowell.github.io/chauffeur) working against v8 (related build **8.0.0-alpha.52**).\r\n\r\nFor this, I need to start Umbraco, and with the removal of the old `BootManager` concept I now need to use an `IRuntime`.\r\n\r\nTo represent as much of Umbraco's true nature as possible I decided to use the `CoreRuntime` class as the runtime I create, given that you can trace the web startup from the `UmbracApplication` -> `WebRuntime` -> `UmbracoApplicationBase.Application_Start` -> `IRuntime.Boot` and the `WebRuntime` extends `CoreRuntime`.\r\n\r\nNow if I create my own implementation of `UmbracoApplicationBase` and pass an instance to a new `CoreRuntime` and simulate the call to `Application_Start` the runtime boots but errors with the following error message:\r\n\r\n```\r\n2018-11-18 20:48:04,079 [P4572/D2/T1] ERROR  Umbraco.Core.Runtime.CoreRuntime - Boot failed. (2291ms) [Timing 2292a5b]\r\nUmbraco.Core.Exceptions.BootFailedException: Could not get parameter of type System.Collections.Generic.IEnumerable`1[[AutoMapper.Profile, AutoMapper, Version=7.0.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005]] for component Umbraco.Core.Runtime.CoreRuntimeComponent. ---> System.InvalidOperationException: Unable to resolve type: System.Collections.Generic.IEnumerable`1[AutoMapper.Profile], service name:  ---> System.InvalidOperationException: Unresolved dependency [Target Type: Umbraco.Web.Models.Mapping.MemberMapperProfile], [Parameter: tabsAndPropertiesResolver(Umbraco.Web.Models.Mapping.MemberTabsAndPropertiesResolver)], [Requested dependency: ServiceType:Umbraco.Web.Models.Mapping.MemberTabsAndPropertiesResolver, ServiceName:] ---> System.InvalidOperationException: Unresolved dependency [Target Type: Umbraco.Web.Models.Mapping.MemberTabsAndPropertiesResolver], [Parameter: umbracoContextAccessor(Umbraco.Web.IUmbracoContextAccessor)], [Requested dependency: ServiceType:Umbraco.Web.IUmbracoContextAccessor, ServiceName:] ---> System.InvalidOperationException: Unresolved dependency [Target Type: Umbraco.Web.HybridUmbracoContextAccessor], [Parameter: httpContextAccessor(Umbraco.Web.IHttpContextAccessor)], [Requested dependency: ServiceType:Umbraco.Web.IHttpContextAccessor, ServiceName:]\r\n   at LightInject.ServiceContainer.GetEmitMethodForDependency(Dependency dependency)\r\n   at LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)\r\n   at LightInject.ServiceContainer.EmitConstructorDependencies(ConstructionInfo constructionInfo, IEmitter emitter, Action`1 decoratorTargetEmitter)\r\n   at LightInject.ServiceContainer.EmitNewInstanceUsingImplementingType(IEmitter emitter, ConstructionInfo constructionInfo, Action`1 decoratorTargetEmitMethod)\r\n   at LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter)\r\n   at LightInject.ServiceContainer.EmitNewInstanceWithDecorators(ServiceRegistration serviceRegistration, IEmitter emitter)\r\n   at LightInject.ServiceContainer.<>c__DisplayClass192_0.<ResolveEmitMethod>b__2(IEmitter ms)\r\n   at LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action`1 serviceEmitter)\r\n   at LightInject.ServiceContainer.<>c__DisplayClass193_0.<EmitLifetime>b__0()\r\n   at LightInject.PerContainerLifetime.GetInstance(Func`1 createInstance, Scope scope)\r\n   at LightInject.ServiceContainer.EmitLifetime(ServiceRegistration serviceRegistration, Action`1 emitMethod, IEmitter emitter)\r\n   at LightInject.ServiceContainer.<>c__DisplayClass192_0.<ResolveEmitMethod>b__1(IEmitter methodSkeleton)\r\n   at LightInject.ServiceContainer.<>c__DisplayClass147_0.<CreateEmitMethodWrapper>b__0(IEmitter ms)\r\n   at LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)\r\n   --- End of inner exception stack trace ---\r\n   at LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)\r\n   at LightInject.ServiceContainer.EmitConstructorDependencies(ConstructionInfo constructionInfo, IEmitter emitter, Action`1 decoratorTargetEmitter)\r\n   at LightInject.ServiceContainer.EmitNewInstanceUsingImplementingType(IEmitter emitter, ConstructionInfo constructionInfo, Action`1 decoratorTargetEmitMethod)\r\n   at LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter)\r\n   at LightInject.ServiceContainer.EmitNewInstanceWithDecorators(ServiceRegistration serviceRegistration, IEmitter emitter)\r\n   at LightInject.ServiceContainer.<>c__DisplayClass192_0.<ResolveEmitMethod>b__0(IEmitter methodSkeleton)\r\n   at LightInject.ServiceContainer.<>c__DisplayClass147_0.<CreateEmitMethodWrapper>b__0(IEmitter ms)\r\n   at LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)\r\n   --- End of inner exception stack trace ---\r\n   at LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)\r\n   at LightInject.ServiceContainer.EmitConstructorDependencies(ConstructionInfo constructionInfo, IEmitter emitter, Action`1 decoratorTargetEmitter)\r\n   at LightInject.ServiceContainer.EmitNewInstanceUsingImplementingType(IEmitter emitter, ConstructionInfo constructionInfo, Action`1 decoratorTargetEmitMethod)\r\n   at LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter)\r\n   at LightInject.ServiceContainer.EmitNewInstanceWithDecorators(ServiceRegistration serviceRegistration, IEmitter emitter)\r\n   at LightInject.ServiceContainer.<>c__DisplayClass192_0.<ResolveEmitMethod>b__0(IEmitter methodSkeleton)\r\n   at LightInject.ServiceContainer.EmitNewArray(IList`1 emitMethods, Type elementType, IEmitter emitter)\r\n   at LightInject.ServiceContainer.<>c__DisplayClass182_0.<CreateEmitMethodForEnumerableServiceServiceRequest>b__6(IEmitter e)\r\n   at LightInject.ServiceContainer.<>c__DisplayClass147_0.<CreateEmitMethodWrapper>b__0(IEmitter ms)\r\n   at LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action`1 serviceEmitter)\r\n   at LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError)\r\n   --- End of inner exception stack trace ---\r\n   at LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError)\r\n   at LightInject.ServiceContainer.CreateDefaultDelegate(Type serviceType, Boolean throwError)\r\n   at LightInject.ServiceContainer.TryGetInstance(Type serviceType)\r\n   at Umbraco.Core.Components.BootLoader.GetParameter(Type componentType, Type parameterType)\r\n   --- End of inner exception stack trace ---\r\n   at Umbraco.Core.Components.BootLoader.GetParameter(Type componentType, Type parameterType)\r\n   at Umbraco.Core.Components.BootLoader.<>c__DisplayClass17_0.<InitializeComponents>b__1(ParameterInfo x)\r\n   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()\r\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\r\n   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\r\n   at Umbraco.Core.Components.BootLoader.InitializeComponents()\r\n   at Umbraco.Core.Components.BootLoader.Boot(IEnumerable`1 componentTypes, RuntimeLevel level)\r\n   at Umbraco.Core.Runtime.CoreRuntime.Boot(ServiceContainer container)\r\n```\r\n\r\nThe reason this fails is that the [`BootLoader.GetParameter` method](https://github.com/umbraco/Umbraco-CMS/blob/temp8/src/Umbraco.Core/Components/BootLoader.cs#L335) tries to resolve a type from the container that hasn't been registered to invoke the [`CoreRuntimeComponent.Initalize` method](https://github.com/umbraco/Umbraco-CMS/blob/temp8/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs#L125) which takes an `IEnumerable<Automapper.Profile>` argument.\r\n\r\nThis happens because none of the Automapper profiles were loaded, and it seems they are loaded via the [`WebMappingProfilesCompositionRoot` in the `WebRuntimeComponent.Compose` method](https://github.com/umbraco/Umbraco-CMS/blob/temp8/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs#L69).\r\n\r\nIf I change my code to create an instance of the `WebRuntime` rather than `CoreRuntime` it works, but throws a bunch of (ultimately swallowed) exceptions around there being no `HttpContext`.\r\n\r\n## Possible fixes\r\n\r\nThere are a few different fixes I can think of:\r\n\r\n1. Allow `null` to be passed into the `Initialize` method of a `RuntimeComponent`, currently, it hard-blocks that (and force handling of nulls)\r\n2. Move the `WebMappingProfilesCompositionRoot` registration into the `CoreRuntimeComponent.Compose`\r\n3. Create a no-op `Automapper.Profile` which I register as part of Chauffeur\r\n\r\nUltimately I don't know the impact of _not_ having those types registered if I'm only interested in the services (I'd assume given they are in the Web binary it shouldn't be _that_ big a problem...), still haven't dug that deep 😜."},"comment":{"url":"https://api.github.com/repos/umbraco/Umbraco-CMS/issues/comments/440527920","html_url":"https://github.com/umbraco/Umbraco-CMS/issues/3707#issuecomment-440527920","issue_url":"https://api.github.com/repos/umbraco/Umbraco-CMS/issues/3707","id":440527920,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDUyNzkyMA==","user":{"login":"aaronpowell","id":434140,"node_id":"MDQ6VXNlcjQzNDE0MA==","avatar_url":"https://avatars0.githubusercontent.com/u/434140?v=4","gravatar_id":"","url":"https://api.github.com/users/aaronpowell","html_url":"https://github.com/aaronpowell","followers_url":"https://api.github.com/users/aaronpowell/followers","following_url":"https://api.github.com/users/aaronpowell/following{/other_user}","gists_url":"https://api.github.com/users/aaronpowell/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronpowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronpowell/subscriptions","organizations_url":"https://api.github.com/users/aaronpowell/orgs","repos_url":"https://api.github.com/users/aaronpowell/repos","events_url":"https://api.github.com/users/aaronpowell/events{/privacy}","received_events_url":"https://api.github.com/users/aaronpowell/received_events","type":"User","site_admin":false},"created_at":"2018-11-21T04:40:04Z","updated_at":"2018-11-21T04:40:04Z","author_association":"CONTRIBUTOR","body":"@Shazwazza haha yeah I know, I decided to delete `System.Web` and wanted to see what went 💥.\r\n\r\nIt wasn't as bad as I expected, the hardest stuff to handle would be the caching stuff."}}
{"actor":{"display_login":"aaronpowell"}}