Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: In place Update of Microsoft.Extensions.* to Version 9.0.0 in a .NET 8 application does not work. #5644

Open
DerAlbertCom opened this issue Nov 14, 2024 · 5 comments
Labels
bug This issue describes a behavior which is not expected - a bug. untriaged waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue.

Comments

@DerAlbertCom
Copy link

DerAlbertCom commented Nov 14, 2024

Description

Because of open-telemetry/opentelemetry-dotnet#5973

I tried to update our .NET 8 Projects to use V9.0.0 of Microsoft.Extensions.* and System.Text.*, but stay on .NET 8 as a TFM.

But we have now we have strange but Dependency Injection Issues, which do not happen with the v8.0.x packages.

It could be wrong stuff in our code, or other dependencies. I tested two Projects.

Do we need to update more? The Applications are compiling fine.

Reproduction Steps

I updated two of our Projects (as a test) to use the V9.0.0 Extensions with these two RegEx Replaces (we are using Central Package Management), but the TargetFramework is still .NET 8.0 and also the .NET 9 SDK is not installed. yet.

<PackageVersion Include=\"Microsoft\.Extensions\.(\S+)\" Version=\"8.(.*)\"(\s*)\/>
<PackageVersion Include=\"Microsoft\.Extensions\.$1\" Version=\"9.0.0\"$3\/>

<PackageVersion Include=\"System\.Text\.(\S+)\" Version=\"8.(.*)\"(\s*)\/>
<PackageVersion Include=\"System\.Text\.$1\" Version=\"9.0.0\"$3\/>

Everything compiles fine. But does not run.

But at runtime we have IoC Issues, locally and on the Buildserver.

Expected behavior

Just works ;)

Actual behavior

IoC is not resolving some Services (for whatever Reason). IoC Problem in both Projects, but not on everything.

it could be a IoC Construction Problem on our Side, but then the message is not very helpful. Like when we put Scoped Services in Singleton we get a helpful message).

Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Carmen.Position.Core.Intraday.Service.TradingRunFactory Lifetime: Transient ImplementationType: Carmen.Position.Core.Intraday.Service.TradingRunFactory': Unable to resolve service for type 'Carmen.Position.Core.PhysicalPosition.IPhysicalPositionService' while attempting to activate 'Carmen.Position.Core.Intraday.Service.PhysicalPositionService'.) (Error while validating the service descriptor 'ServiceType: Carmen.Position.Core.Intraday.Service.PhysicalPositionService Lifetime: Transient ImplementationType: Carmen.Position.Core.Intraday.Service.PhysicalPositionService': Unable to resolve service for type 'Carmen.Position.Core.PhysicalPosition.IPhysicalPositionService' while attempting to activate 'Carmen.Position.Core.Intraday.Service.PhysicalPositionService'.) (Error while validating the service descriptor 'ServiceType: Carmen.Position.Core.Intraday.SecondaryReserve.SecondaryReserveAuctionResultService Lifetime: Transient ImplementationType: Carmen.Position.Core.Intraday.SecondaryReserve.SecondaryReserveAuctionResultService': Unable to resolve service for type 'Carmen.Position.Infrastructure.GasNomination.Service.IAuthenticationService' while attempting to activate 'Carmen.Position.Infrastructure.Intraday.SecondaryReserve.MarketDataApiClient'.) (Error while validating the service descriptor 'ServiceType: Carmen.Position.Core.Intraday.SecondaryReserve.SecondaryReserveAuctionsService Lifetime: Transient ImplementationType: Carmen.Position.Core.Intraday.SecondaryReserve.SecondaryReserveAuctionsService': Unable to resolve service for type 'Carmen.Position.Infrastructure.GasNomination.Service.IAuthenticationService' while attempting to activate 'Carmen.Position.Infrastructure.Intraday.SecondaryReserve.MarketDataApiClient'.) (Error while validating the service descriptor 'ServiceType: Carmen.Position.Core.Intraday.Calculator.GridBalanceCalculator Lifetime: Transient ImplementationType: Carmen.Position.Core.Intraday.Calculator.GridBalanceCalculator': Unable to resolve service for type 'Carmen.Position.Infrastructure.GasNomination.Service.IAuthenticationService' while attempting to activate 'Carmen.Position.Infrastructure.Intraday.SecondaryReserve.MarketDataApiClient'.) (Error while validating the service descriptor 'ServiceType: Carmen.Position.Core.Intraday.Service.CloseTradedPositionsService Lifetime: Transient ImplementationType: Carmen.Position.Core.Intraday.Service.CloseTradedPositionsService': Unable to resolve service for type 'Carmen.Position.Core.PhysicalPosition.IPhysicalPositionService' while attempting to activate 'Carmen.Position.Core.Intraday.Service.PhysicalPositionService'.) (Error while validating the service descriptor 'ServiceType: CS.Common.Mediator.IMediatorCommandHandler`1[Carmen.Position.Core.Intraday.CloseAutomatedTradedPositionsCommand] Lifetime: Transient ImplementationType: Carmen.Position.Core.Intraday.CloseAutomatedTradedPositionsCommand+Handler': Unable to resolve service for type 'Carmen.Position.Core.PhysicalPosition.IPhysicalPositionService' while attempting to activate 'Carmen.Position.Core.Intraday.Service.PhysicalPositionService'.) (Error while validating the service descriptor 'ServiceType: CS.Common.Mediator.IMediatorCommandHandler`1[Carmen.Position.Core.Intraday.CloseTradedPositionsCommand] Lifetime: Transient ImplementationType: Carmen.Position.Core.Intraday.CloseTradedPositionsCommand+Handler': Unable to resolve service for type 'Carmen.Position.Core.PhysicalPosition.IPhysicalPositionService' while attempting to activate 'Carmen.Position.Core.Intraday.Service.PhysicalPositionService'.) (Error while validating the service descriptor 'ServiceType: Carmen.Position.Core.Intraday.SecondaryReserve.IMarketDataService Lifetime: Scoped ImplementationType: Carmen.Position.Core.Intraday.SecondaryReserve.MarketDataService': Unable to resolve service for type 'Carmen.Position.Infrastructure.GasNomination.Service.IAuthenticationService' while attempting to activate 'Carmen.Position.Infrastructure.Intraday.SecondaryReserve.MarketDataApiClient'.) (Error while validating the service descriptor 'ServiceType: Carmen.Position.Infrastructure.Intraday.SecondaryReserve.IMarketDataApiClient Lifetime: Scoped ImplementationType: Carmen.Position.Infrastructure.Intraday.SecondaryReserve.MarketDataApiClient': Unable to resolve service for type 'Carmen.Position.Infrastructure.GasNomination.Service.IAuthenticationService' while attempting to activate 'Carmen.Position.Infrastructure.Intraday.SecondaryReserve.MarketDataApiClient'.)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)
   at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)
   at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder)
   at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter`1.CreateServiceProvider(Object containerBuilder)
   at Microsoft.Extensions.Hosting.HostBuilder.InitializeServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()

Regression?

I think so, just updated the Dependencies, it break the Application.

Known Workarounds

No response

Configuration

.NET SDK:
Version: 8.0.403
Commit: c64aa40a71
Workload version: 8.0.400-manifests.e99c892e
MSBuild version: 17.11.9+a69bbaaf5

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.403\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
[aspire]
Installation Source: VS 17.11.35327.3
Manifest Version: 8.1.0/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.1.0\WorkloadManifest.json
Install Type: FileBased

Host:
Version: 8.0.10
Architecture: x64
Commit: 81cabf2857

.NET SDKs installed:
2.2.207 [C:\Program Files\dotnet\sdk]
6.0.427 [C:\Program Files\dotnet\sdk]
8.0.306 [C:\Program Files\dotnet\sdk]
8.0.403 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Other information

No response

@DerAlbertCom DerAlbertCom added bug This issue describes a behavior which is not expected - a bug. untriaged labels Nov 14, 2024
@RussKie
Copy link
Member

RussKie commented Nov 14, 2024

...use V9.0.0 of Microsoft.Extensions.*

Which extensions libraries are you having troubles with? Microsoft.Extensions.* come from at least three different repos.

Please note, the libraries hosted in this repo are covered by the specific support policy: https://dotnet.microsoft.com/platform/support/policy/extensions.

@RussKie RussKie added the waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue. label Nov 14, 2024
@DerAlbertCom
Copy link
Author

DerAlbertCom commented Nov 16, 2024

Where should I know where to look which is the supported repository, I wrote it here because of the DependencyInjection Exceptions. And I looked in the repository if there is the source of that. Make it easy to support problems.

These are the direct references Extensions in our Project, I upgraded all of these to 9.0.0, but I don't know about the transitive dependencies.

It may be possible to upgrade to 9.0.0 as the Transitive ones. To add all Extensions to the Directory.Packages.props files.
The Point is, currently this kind of Version upgrade breaks stuff. The 9.0.0 is forced in our case by OpenTelemetry (and I'm being certain other packages will come in the near future)

If you need additional information, please let me HOW to give you useful Info, and asking for a minimal reproduction is not helpful with this kind of exception so early in the starting phase of a complex software.

I can provide further Information you request, be willing to run something to gather more Information for you. Like seeing which dependencies are finally being used in the application.

Project A:

    <PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
    <PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
    <PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
    <PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
    <PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="8.0.11" />
    <PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="8.0.11" />
    <PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
    <PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
    <PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="8.10.0" />

Project B:

 <PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
    <PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
    <PackageVersion Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" />
    <PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
    <PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
    <PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="8.0.2" />
    <PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
    <PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="8.0.11" />
    <PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
    <PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
    <PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
    <PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="8.10.0" />

@dotnet-policy-service dotnet-policy-service bot removed the waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue. label Nov 16, 2024
@DerAlbertCom
Copy link
Author

It seemed that JUST the Dependency Validation was the problem (first impression after giving it some investigation), then I dug a little.

Then I located the issue in our code, this breaking change in 9.0.0

https://learn.microsoft.com/en-us/dotnet/core/compatibility/aspnet-core/9.0/hostbuilder-validation

@martincostello
Copy link
Member

martincostello commented Nov 16, 2024

Where should I know where to look which is the supported repository

One way (but not necessarily intuitive) to find out is to look at the package in NuGet and click on the Source repository link.

The packages are built with Git metadata that will link you to the repo where the source is, so in the case of Microsoft.Extensions.* it should take you to the correct repo out of runtime, aspnetcore and extensions.

@RussKie
Copy link
Member

RussKie commented Nov 18, 2024

Where should I know where to look which is the supported repository

One way (but not necessarily intuitive) to find out is to look at the package in NuGet and click on the Source repository link.

The packages are built with Git metadata that will link you to the repo where the source is, so in the case of Microsoft.Extensions.* it should take you to the correct repo out of runtime, aspnetcore and extensions.

Image

Where should I know where to look which is the supported repository, I wrote it here because of the DependencyInjection Exceptions. And I looked in the repository if there is the source of that.

DependencyInjection comes from dotnet/runtime, it has some additional implementations in dotnet/aspnetcore and some implementations in this repo. I asked you which one you're having troubles with so we could direct your issue to the right team.

Make it easy to support problems.

Suggestions are welcome.

These are the direct references Extensions in our Project, I upgraded all of these to 9.0.0, but I don't know about the transitive dependencies.

It may be possible to upgrade to 9.0.0 as the Transitive ones. To add all Extensions to the Directory.Packages.props files. The Point is, currently this kind of Version upgrade breaks stuff. The 9.0.0 is forced in our case by OpenTelemetry (and I'm being certain other packages will come in the near future)

The issue is with the OT then?

If you need additional information, please let me HOW to give you useful Info, and asking for a minimal reproduction is not helpful with this kind of exception so early in the starting phase of a complex software.

Put yourself in our shoes - without a small repro or without knowing what exactly is causing an issue we can't be very helpful.

It seemed that JUST the Dependency Validation was the problem (first impression after giving it some investigation), then I dug a little.

Then I located the issue in our code, this breaking change in 9.0.0

learn.microsoft.com/en-us/dotnet/core/compatibility/aspnet-core/9.0/hostbuilder-validation

So, is your issue is resolved, or do you require some further assistance?

@RussKie RussKie added the waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue. label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes a behavior which is not expected - a bug. untriaged waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue.
Projects
None yet
Development

No branches or pull requests

3 participants