[9.0.100-rc.1.24406.1] EasyCMS app launch failed with 'Multiple constructors accepting all given argument types have been found in type 'Microsoft.AspNetCore.CookiePolicy.CookiePolicyMiddleware' exception
We are doing Application compatibility testing with the application against the latest .NET 9 SDK. When running the application with the .NET 9.0 build (9.0.100-rc.1.24406.1), it failed launch with below exception message:
System.InvalidOperationException: 'Multiple constructors accepting all given argument types have been found in type 'Microsoft.AspNetCore.CookiePolicy.CookiePolicyMiddleware'. There should only be one applicable constructor.'
After the investigation, it is related to a .NET 9 breaking change https://github.com/aspnet/Announcements/issues/514
Recommended action If this happens and you can't upgrade to a dependency injection container that implements IServiceProviderIsService, you can add ActivatorUtilitiesConstructorAttribute to the preferred constructor of the affected middleware type.
Steps To Reproduce
- Open "..\EasyCMS\App\Atlass.Framework.Web.runtimeconfig.json" file .
- Change the "Atlass.Framework.Web.runtimeconfig.json" file to let the app run against with dotnet-sdk-9.0.100-rc.1.24406.1
"framework": {
"name": "Microsoft.AspNetCore.App",
"version": "9.0.0-rc.1.24405.8"
},
- Launch ..\EasyCMS\App\Atlass.Framework.Web.exe.
Expected Result: Launch successfully.
Actual Result: Launch failed with below error in Command prompt window:
Please refer to more information from https://github.com/dotnet/aspnetcore/issues/57231