You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In ASP.NET Core 2.0 we are removing the Microsoft.Extensions.PlatformAbstractions package as it is no longer necessary to maintain this abstraction. Consumers of this package will need to replace their use of these APIs with the standard .NET APIs as follows:
Microsoft.Extensions.PlatformAbstractions
Equivalent .NET API
ApplicationEnvironment.ApplicationBasePath
System.AppContext.BaseDirectory or System.AppDomain.CurrentDomain.BaseDirectory
ApplicationEnvironment.ApplicationName
System.Reflection.Assembly.GetEntryAssembly().GetName().Name or System.AppDomain.CurrentDomain.SetupInformation.ApplicationName
System.Reflection.Assembly.GetEntryAssembly().GetCustomAttribute<TargetFrameworkAttribute>().FrameworkName or System.AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName
Note: As part of this change, you could encounter the following error if you build your WebHost by injecting IStartup directly into the DI container, rather than calling .UseStartup or .Configure:
Unhandled Exception: System.ArgumentException: A valid non-empty application name must be provided.
Parameter name: applicationName
at Microsoft.AspNetCore.Hosting.Internal.HostingEnvironmentExtensions.Initialize(IHostingEnvironment hostingEnvironment, String applicationName, String contentRootPath, WebHostOptions options)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at ConsoleApp11.Program.Main(String[] args) in C:\Users\dfowler\documents\visual studio 2017\Projects\ConsoleApp11\ConsoleApp11\Program.cs:line 11
This occurs because we need to get the name of the application. Previously, we used some heuristics to detect it, but we removed some of them in 2.0. In the scenario above, where IStartup is manually injected into the container, add the following call to your WebHostBuilder set-up sequence:
WebHost.CreateDefaultBuilder(args)
// ... other Web Host configuration calls
.UseSetting(WebHostDefaults.ApplicationKey, "[Application Name]")
NOTE: This is only required in 2.0 and only when you do NOT call .UseStartup or .Configure
In ASP.NET Core 2.0 we are removing the
Microsoft.Extensions.PlatformAbstractions
package as it is no longer necessary to maintain this abstraction. Consumers of this package will need to replace their use of these APIs with the standard .NET APIs as follows:System.AppContext.BaseDirectory
orSystem.AppDomain.CurrentDomain.BaseDirectory
System.Reflection.Assembly.GetEntryAssembly().GetName().Name
orSystem.AppDomain.CurrentDomain.SetupInformation.ApplicationName
System.Reflection.Assembly.GetEntryAssembly().GetName().Version
System.Reflection.Assembly.GetEntryAssembly().GetCustomAttribute<TargetFrameworkAttribute>().FrameworkName
orSystem.AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName
See aspnet/PlatformAbstractions#50 for more detail or to discuss this change.
The text was updated successfully, but these errors were encountered: