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

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0 #2084

Closed
DaleyKD opened this issue Oct 25, 2023 · 8 comments · Fixed by #2185
Assignees

Comments

@DaleyKD
Copy link

DaleyKD commented Oct 25, 2023

Please, fill the following sections to help us fix the issue

What happened:

fail: Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService[104]
      Health check azure_blob_storage threw an unhandled exception after 16.2131ms
      System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
      File name: 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
         at HealthChecks.Azure.Storage.Blobs.AzureBlobStorageHealthCheck.CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken)
         at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
         at HealthChecks.Azure.Storage.Blobs.AzureBlobStorageHealthCheck.CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken)
         at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.RunCheckAsync(HealthCheckRegistration registration, CancellationToken cancellationToken)

What you expected to happen:
I shouldn't need to manually add a reference to Microsoft.Bcl.AsyncInterfaces v7.0.0.0.

How to reproduce it (as minimally and precisely as possible):
Add a health check for Azure Blob Storage.
Here are my package references:

    <PackageReference Include="AspNetCore.HealthChecks.Azure.Storage.Blobs" Version="7.0.0" />
    <PackageReference Include="AspNetCore.HealthChecks.AzureApplicationInsights" Version="7.0.0" />
    <PackageReference Include="AspNetCore.HealthChecks.AzureKeyVault" Version="7.0.0" />
    <PackageReference Include="AspNetCore.HealthChecks.Redis" Version="7.0.1" />
    <PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Azure" Version="1.7.0" />
    <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="7.0.13" />
// Configure Blob Service Client for use in Health Checks
services.AddAzureClients(x =>
{
    var azureStorageConnectionString = configuration.GetConnectionString("DataProtectionAzureStorage");
    var dataProtectionSection = configuration.GetSection("DataProtection");
    var azureStorageUriString = dataProtectionSection["StorageUri"];

    if (!string.IsNullOrEmpty(azureStorageConnectionString))
    {
        x.AddBlobServiceClient(azureStorageConnectionString);
    }
    else if (!string.IsNullOrWhiteSpace(azureStorageUriString))
    {
        x.AddBlobServiceClient(new Uri(azureStorageUriString));
        x.UseCredential(new DefaultAzureCredential());
    }
});

services.AddHealthChecks().AddAzureBlobStorage();

Source code sample:

Anything else we need to know?:

Environment:

  • .NET Core version: 7.0
  • Healthchecks version: 7.0
  • Operative system: Windows 11
  • Others:
@insylogo
Copy link

insylogo commented Nov 7, 2023

Same issue here. Shouldn't need Microsoft.Bcl.AsyncInterfaces with dotnet 7 or later, but it's coming up for me when using blob storage health checks.

@blogcraft
Copy link

Same problem here... :/

@DaleyKD
Copy link
Author

DaleyKD commented Nov 14, 2023

I could be wrong, but I upgraded to .NET 8 today (as much as I could). In doing so, I no longer needed a reference to this. Something must have updated it's dependency. I didn't take any additional time to investigate.

@blogcraft
Copy link

🦖 Didn't know it was already out! Well, I will test it and see what happens.

@DaleyKD
Copy link
Author

DaleyKD commented Nov 14, 2023

@blogcraft - Today is .NET 8 Release Day. https://www.dotnetconf.net/

@sungam3r
Copy link
Collaborator

sungam3r commented Dec 3, 2023

Microsoft.Bcl.AsyncInterfaces dependency is a known PITA.

@sungam3r
Copy link
Collaborator

sungam3r commented Dec 4, 2023

#2109

@sungam3r
Copy link
Collaborator

sungam3r commented Dec 4, 2023

Additional info here #1724 (comment) and below.

@eerhardt eerhardt self-assigned this Apr 1, 2024
eerhardt added a commit that referenced this issue Apr 1, 2024
This ensures that when libraries and apps who depend on the HealthChecks libraries get the correct transitive dependences for .NETCoreApp TFMs (for example Microsoft.Bcl.AsyncInterfaces).

This follows the following [guidance](https://learn.microsoft.com/dotnet/standard/library-guidance/cross-platform-targeting):

✔️ CONSIDER multi-targeting even if your source code is the same for all targets, when your project has any library or package dependencies.

Fix #2180
Fix #2084
Fix #2163
adamsitnik added a commit that referenced this issue Apr 2, 2024
* Ensure all HealthChecks libraries have a .NETCoreApp TFM.

This ensures that when libraries and apps who depend on the HealthChecks libraries get the correct transitive dependences for .NETCoreApp TFMs (for example Microsoft.Bcl.AsyncInterfaces).

This follows the following [guidance](https://learn.microsoft.com/dotnet/standard/library-guidance/cross-platform-targeting):

✔️ CONSIDER multi-targeting even if your source code is the same for all targets, when your project has any library or package dependencies.

Fix #2180
Fix #2084
Fix #2163

* Add [SupportedOSPlatform] to the HealthChecks.System.approved.txt

---------

Co-authored-by: Adam Sitnik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants