-
Notifications
You must be signed in to change notification settings - Fork 311
RC1(15958): Unable to resolve service for type 'Microsoft.AspNet.Hosting.IApplicationLifetime' #434
Comments
@davidfowl @pakrym, is this yours? |
@xatabhk Please provide a repro |
Steps to reproduce the error:
When RC1 (now 15838) from https://www.myget.org/F/aspnetvnext/api/v3/index.json used, there is no this error. |
Did you update to RC1 packages as well? Using RC1 DNX with beta8 packages is not supported, and it's best to pull your DNX and packages from the same feed to make sure they're in sync. |
Yes. I created two new Web Apps with Wizard, one for RC1 15958 and another for RC1 15938 and wiped out all RC1 dnx runtimes and all packages before each test. |
@xatabhk You has a mismatch of versions. Either use * or use beta8 and it'll work either way. |
It was unlikely a mismatch of versions, since I used * and restored all files starting with a clean slate by wiping out all previous versions before each test. |
@xatabhk, Did you used the |
Ok, I've found it. The IApplicationLifetime service is added here:
However, if there's an exception loading your startup class then it gets caught and we rebuild the app services without IApplicationLifetime:
Workaround: Run your app under the debugger with all first-chance exceptions enabled. This will let you see the original error. |
Good catch! |
Running website under IISExpress in IDE gives no detailed error; but 'dnx web' prints the following error messages:
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNet.Hosting.IApplicationLifetime' while attempting to activate 'Microsoft.AspNet.Server.Kestrel.ServerFactory'.
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type)
at Microsoft.AspNet.Hosting.Server.ServerLoader.LoadServerFactory(String assemblyName)
at Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureServer()
at Microsoft.AspNet.Hosting.Internal.HostingEngine.BuildApplication()
at Microsoft.AspNet.Hosting.Internal.HostingEngine.Start()
at Microsoft.AspNet.Hosting.Program.Main(String[] args)
at Microsoft.AspNet.Server.Kestrel.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, String appBase, FrameworkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, BootstrapperContext bootstrapperContext)
at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, BootstrapperContext bootstrapperContext)
The text was updated successfully, but these errors were encountered: