AspNetCore.Diagnostics.HealthChecks icon indicating copy to clipboard operation
AspNetCore.Diagnostics.HealthChecks copied to clipboard

After update package 7.0.0 on asp.net core 6.0 Im geting error

Open phivanloi opened this issue 1 year ago • 17 comments

After update package 7.0.0 on asp.net core 6.0 Im geting error image

phivanloi avatar Aug 01 '23 14:08 phivanloi

Hi,

I've experienced it as well.

Try installing Microsoft.Bcl.AsyncInterfaces in version 7.0.0.

cieciurm avatar Aug 01 '23 19:08 cieciurm

See https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/pull/1720 . This PR explains the problem. @phivanloi What packages exactly do you use? We can add reference to Microsoft.Bcl.AsyncInterfaces as we already did in #1720.

sungam3r avatar Aug 01 '23 20:08 sungam3r

Thanks cieciurm And sungam3r. I'm add line code

<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />

to fix this error.

phivanloi avatar Aug 01 '23 23:08 phivanloi

Hi, I also had the same issue and also fixed it by adding Microsoft.Bcl.AsyncInterfaces to all projects using healthchecks.

However, this is more of a workaround than a fix, isn't it? Shouldn't AspNetCore.Diagnostics.HealthChecks bring it as a dependency if it needs it? Otherwise, the Readme should specify clearly that this dependency must be added alongside AspNetCore.Diagnostics.HealthChecks.

corentinaltepe avatar Aug 02 '23 10:08 corentinaltepe

However, this is more of a workaround than a fix, isn't it?

It's hard to tell.

Shouldn't AspNetCore.Diagnostics.HealthChecks bring it as a dependency if it needs it?

Please read https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/pull/1692#issuecomment-1448434526 . It looks like an issue on MS side. HealthChecks' packages are just intermediate victim. I'm open to suggestions and best practices.

@corentinaltepe Please look into deps file in your output folder and search exact package that depends on Microsoft.Bcl.AsyncInterfaces.

sungam3r avatar Aug 02 '23 10:08 sungam3r

Hi @sungam3r.

Is this what you were looking for? image

corentinaltepe avatar Aug 02 '23 13:08 corentinaltepe

Also ran into this on our .NET 6 app. Caused by the dependency on Microsoft.Extensions.Diagnostics.HealthChecks v7, which brings in other .NET 7 deps. We've avoided using .NET 7 packages in our .NET 6 apps due to that not feeling right (does every .NET 7 package guarantee backwards compatibility with ASP.NET Core 6? Seems unlikely). Unless you add a TFM for .NET 6 that targets Microsoft.Extensions.Diagnostics.HealthChecks v6, looks like we'll be waiting to upgrade from v6 until we go to .NET 8.

IGx89 avatar Aug 02 '23 16:08 IGx89

This happens even in .NET 7 with AspNetCore.HealthChecks.AzureStorage.

cmeeren avatar Aug 09 '23 05:08 cmeeren

To be honest, I'm not sure if it's related to the AspNetCore.HealthChecks packages.

I've experienced it in a project which didn't use Health Checks.

The setup was:

  • Web project target .net 6
  • Some other project targeting .net standard 2.0 with dependency to Azure.Storage.Blobs
  • Web projects is referencing the other project

On running the web project the described errors occurs.

cieciurm avatar Aug 09 '23 06:08 cieciurm

Hmm, I now removed the Microsoft.Bcl.AsyncInterfaces dependency and it works fine. The only thing that changed, as far as I know, is that I installed the most recent .NET 7 SDK (7.0.400). Perhaps that fixed it?

cmeeren avatar Aug 09 '23 07:08 cmeeren

Hm, scratch that. Still fails on CI.

cmeeren avatar Aug 09 '23 07:08 cmeeren

When installing the version 7.0.0 packages of AspNetCore.HealthChecks.AzureServiceBus or AspNetCore.HealthChecks.AzureStorage to .net 7 projects it seems that the DLLs target .netstandard 2.0. The version 6 packages targeted .NETCoreApp, Version=v6.0 when installing to .net 6 project. Seems like a version mismatch in the libraries. .NET 7 shouldn't need to reference the Microsoft.Bcl.AsyncInterfaces library.

EDIT: OK so this is a targeting issue. You'll want to multi target these libraries and add .net 7 target for version 7 packages.

OldWiseLlama avatar Sep 12 '23 05:09 OldWiseLlama

We had the same problem in ASP.NET Core application in .NET 6 project, when upgrading the AspNetCore.HealthChecks.Oracle nuget package from version 6.x to version 7.x

Currently, the AspNetCore.HealthChecks.Oracle package version 7.x now has a dependency on Microsoft.Extensions.Diagnostics.HealthChecks (>= 7.0.9)

Meanwhile, the AspNetCore.HealthChecks.Oracle package in version 6.x had this dependency: Microsoft.Extensions.Diagnostics.HealthChecks (>= 6.0.3)

In fact, all nuget packages of Microsoft.Extension.* version 7.x run in .NET 6 just fine, without any problems (they all have a target on net6.0). So maybe it was not worth changing the minimum version in the dependency to Microsoft.Extensions.Diagnostics.HealthChecks.

Please consider changing the dependency from Microsoft.Extensions.Diagnostics.HealthChecks (>= 7.0.9) to Microsoft.Extensions.Diagnostics.HealthChecks (>= 6.0.3), or having separate targets for net6.0 and net7.0.

OlegUfaev avatar Sep 19 '23 11:09 OlegUfaev

Please consider changing the dependency from Microsoft.Extensions.Diagnostics.HealthChecks (>= 7.0.9) to Microsoft.Extensions.Diagnostics.HealthChecks (>= 6.0.3), or having separate targets for net6.0 and net7.0.

Well... Of course it's possible but I think it goes against current targeting design when v X.* versions of packages are targeted at v X.* version of NET.

ping @unaizorrilla @adamsitnik

sungam3r avatar Dec 03 '23 19:12 sungam3r

Well... Of course it's possible but I think it goes against current targeting design when v X.* versions of packages are targeted at v X.* version of NET.

If you are using .NET X you should be using X.* version of our packages.

adamsitnik avatar Dec 04 '23 06:12 adamsitnik

Guys, what do you think about https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/pull/1980#issuecomment-1924352450 ?

sungam3r avatar Feb 02 '24 17:02 sungam3r