Description
Description
Previously no validation was enabled by default.
Now, when in Development environment ValidateOnBuild and ValidateScopes will be enabled.
Version
.NET 9 Preview 7
Previous behavior
ValidateOnBuild and ValidateScopes default to false and are only enabled when users set them with UseDefaultServiceProvider.
New behavior
ValidateOnBuild and ValidateScopes will be set to true, when in the development environment and options have not be set with UseDefaultServiceProvider.
Type of breaking change
- Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
- Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
- Behavioral change: Existing binaries might behave differently at run time.
Reason for change
Enabling validation will help catch problems early in application startup rather than later (or not at all) when the application interacts with it's service provider.
Recommended action
No action necessary for applications which validate successfully. If you do see a validation error when testing in development then first try to fix it. If you cannot fix it you can disable validation by calling UseDefaultServiceProvider.
Feature area
ASP.NET Core, Extensions
Affected APIs
Microsoft.Extensions.Hosting.HostBuilder
Microsoft.Extensions.Hosting.HostBuilder.Build()