From fa72b35883dccc39d6d3e9d66e738185f7e3f2f0 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 23 Oct 2015 02:59:50 -0700 Subject: [PATCH] More granualr null checks for platform services --- src/Microsoft.AspNet.Hosting/WebHostBuilder.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs b/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs index 55126d83b7..d3cb534555 100644 --- a/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs +++ b/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs @@ -92,12 +92,28 @@ namespace Microsoft.AspNet.Hosting _configureServices(services); } - if (PlatformServices.Default != null) + if (PlatformServices.Default?.Application != null) { services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Application)); + } + + if (PlatformServices.Default?.Runtime != null) + { services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Runtime)); + } + + if (PlatformServices.Default?.AssemblyLoadContextAccessor != null) + { services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.AssemblyLoadContextAccessor)); + } + + if (PlatformServices.Default?.AssemblyLoaderContainer != null) + { services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.AssemblyLoaderContainer)); + } + + if (PlatformServices.Default?.LibraryManager != null) + { services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.LibraryManager)); }