diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/RequestServicesContainerMiddleware.cs b/src/Microsoft.AspNetCore.Hosting/Internal/RequestServicesContainerMiddleware.cs index fffbd88a56..eec8e5ac2d 100644 --- a/src/Microsoft.AspNetCore.Hosting/Internal/RequestServicesContainerMiddleware.cs +++ b/src/Microsoft.AspNetCore.Hosting/Internal/RequestServicesContainerMiddleware.cs @@ -3,11 +3,8 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Http.Features.Internal; -using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Hosting.Internal { diff --git a/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs b/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs index ff5494b9d6..af249dabcf 100644 --- a/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs +++ b/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs @@ -15,7 +15,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Internal; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Microsoft.Extensions.ObjectPool; using Microsoft.Extensions.PlatformAbstractions; @@ -221,8 +220,11 @@ namespace Microsoft.AspNetCore.Hosting configureLogging(_loggerFactory); } - services.AddSingleton(_loggerFactory); //The configured ILoggerFactory is added as a singleton here. AddLogging below will not add an additional one. - services.AddLogging(); //This is required to add ILogger of T. + //The configured ILoggerFactory is added as a singleton here. AddLogging below will not add an additional one. + services.AddSingleton(_loggerFactory); + + //This is required to add ILogger of T. + services.AddLogging(); services.AddTransient(); @@ -239,17 +241,12 @@ namespace Microsoft.AspNetCore.Hosting services.AddTransient(); // Ensure object pooling is available everywhere. - services.TryAddSingleton(); + services.AddSingleton(); var defaultPlatformServices = PlatformServices.Default; - if (defaultPlatformServices.Application != null) - { - services.TryAddSingleton(defaultPlatformServices.Application); - } - if (defaultPlatformServices.Runtime != null) - { - services.TryAddSingleton(defaultPlatformServices.Runtime); - } + + services.AddSingleton(defaultPlatformServices.Application); + services.AddSingleton(defaultPlatformServices.Runtime); foreach (var configureServices in _configureServicesDelegates) { diff --git a/src/Microsoft.AspNetCore.Hosting/project.json b/src/Microsoft.AspNetCore.Hosting/project.json index 264fc8d40d..8b529b440d 100644 --- a/src/Microsoft.AspNetCore.Hosting/project.json +++ b/src/Microsoft.AspNetCore.Hosting/project.json @@ -38,6 +38,12 @@ "frameworkAssemblies": { "System.Runtime": { "type": "build" + }, + "System.ComponentModel": { + "type": "build" + }, + "System.IO": { + "type": "build" } } },