Closed Junjun-zhao closed 4 months ago
Tagging subscribers to this area: @dotnet/area-extensions-dependencyinjection See info in area-owners.md if you want to be subscribed.
Hi @ericstj, could you please help check and triage this issue? Please kindly help to move to correct team if this is not correct. Thanks very much.
Having a look at the repro to see if I can help find regressing change. These are the runtime changes that would be in that difference of builds: https://github.com/dotnet/runtime/compare/4e278fe17f69ea31fbdcbab74ac47ec6fa84914b...b885a58062434707e7584d29910af429a1ee0107
Tagging subscribers to this area: @dotnet/area-extensions-hosting See info in area-owners.md if you want to be subscribed.
This was regressed with https://github.com/dotnet/runtime/pull/99199 @wcsanders1 @steveharter
So this app only registers the IInstallationLocalizationService
when databaseInstalled
is not set.
https://github.com/grandnode/grandnode/blob/c209758031e88d0279a023a7237b1f68ebd9f4dc/Grand.Services/Infrastructure/DependencyRegistrar.cs#L277-L282
However, it will always register validators, regardless of this: https://github.com/grandnode/grandnode/blob/c209758031e88d0279a023a7237b1f68ebd9f4dc/Grand.Framework/Infrastructure/DependencyRegistrar.cs#L116-L135
The InstallValidator
will fail construction because it doesn't have the IInstallationLocalizationService
https://github.com/grandnode/grandnode/blob/c209758031e88d0279a023a7237b1f68ebd9f4dc/Grand.Web/Validators/Install/InstallValidator.cs#L9-L23
I can fix this in the application by registering the IInstallationLocalizationService
regardless of the databaseInstalled
.
This got me past the first error, but then I hit:
Unable to resolve service for type 'WebEssentials.AspNetCore.Pwa.PwaOptions' while attempting to activate 'WebEssentials.AspNetCore.Pwa.PwaController'.
That's also related to conditional service registration: https://github.com/grandnode/grandnode/blob/c209758031e88d0279a023a7237b1f68ebd9f4dc/Grand.Framework/Infrastructure/Extensions/ServiceCollectionExtensions.cs#L444-L460
I couldn't see why it was trying to create a PwaController
during validation (maybe assembly registration, or someone looking for all Controller instances???), but I was able to remove the conditions on adding the PwaOptions to get past that. Then I hit
'Cannot consume scoped service 'Grand.Domain.Security.SecuritySettings' from singleton 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionResultExecutor`1[Microsoft.AspNetCore.Mvc.RedirectResult]'.'
At this point I stopped hacking. I worked around the change by setting ASPNETCORE_ENVIRONMENT=Staging.
Seems to me like this app even tried to disable validation, but we ignored that:
https://github.com/grandnode/grandnode/blob/c209758031e88d0279a023a7237b1f68ebd9f4dc/Grand.Web/Program.cs#L38-L39
I think we should have cleared _defaultProviderFactoryUsed
with the call to UseDefaultServiceProvider
at least.
@wcsanders1 @steveharter @halter73 could you have a look here? Do you think others might face breaking changes like this with #99199 such that we should revert it, or is this a one off?
Verified and this issue has been fixed on dotnet-sdk-9.0.100-preview.7.24379.15
Description
When run the 3rd party application grandnode with the latest .NET 9 build, it failed to launch that browser displays "can't reach this page". During the debugging, we found it failed with message "Some services are not able to be constructed" and stacktrace shows at
Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor
. Because this app is very complex, and we don't identify a code snippet to reproduce the issue. So, we provided a repro machine for team to investigate. Please refer to the details from "Internal bug"Reproduction Steps
Repro Steps for Debug Source on repro machine: (Please refer to the repro machine from Internal bug ) The machine has dotnet-sdk-9.0.100-preview.7.24366.3 sdk and mongodb installed.
Expected behavior
Loading page successfully.
Actual behavior
Can't reach this page . error details:
Regression?
Yes
Verify Scenarios: 1). Windows 10 22H2 AMD64 + dotnet-sdk-3.1.426: Pass 2). Windows 10 22H2 AMD64 + dotnet-sdk-9.0.100-preview.7.24359.5: Pass 3). Windows 10 22H2 AMD64 + dotnet-sdk-9.0.100-preview.7.24366.3: Fail
Known Workarounds
No response
Configuration
Application Name: grandnode OS: Windows 10 22H2 CPU: X64 .NET Build Number: dotnet-sdk-9.0.100-preview.7.24366.3 App & Source , Repro machine checking at https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2166741
Github Link: https://github.com/grandnode/grandnode
Dotnet Info:
Other information
@dotnet-actwx-bot @dotnet/compat