dotnet / dotnet/aspnetcore

Could not load file or assembly 'Microsoft.AspNetCore.Diagnostics.Abstractions' with .net 7.0.5

Open
#48,244 4 comments 1 reaction 0 assignees View on GitHub
area-middleware feature-diagnostics
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Description

We are experiencing a problem with our .net mvc api running in service fabric which is getting the error `Could not load file or assembly 'Microsoft.AspNetCore.Diagnostics.Abstractions`.

The compile target is .net 7.

I search for other bugs and found the issue dotnet/runtime#3252 and searched for direct package references in our project, but found none.

We deploy the api as a self contained package, so the host runtime shouldn't matter?

### Reproduction Steps

The problem is, that I can't reproduce it locally. It just happens, when it is deployed. But we can't find the cause.

### Expected behavior

Not seeing an error

### Actual behavior

Throws an exception:

```
Could not load file or assembly 'Microsoft.AspNetCore.Diagnostics.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Type: System.IO.FileNotFoundException
File not found: Microsoft.AspNetCore.Diagnostics.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Stack Trace: at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.g__Awaited|8_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
at Microsoft.AspNetCore.Server.HttpSys.RequestContext`1.ExecuteAsync()
at Microsoft.AspNetCore.Server.HttpSys.RequestContext`1.ExecuteAsync()
```

### Regression?

It worked for month using .net 6 before. We just started to see this happen after upgrading to .net 7

### Known Workarounds

We don't have one.

### Configuration

- Which version of .NET is the code running on?
.net 7.0.5

- What OS and version, and what distro if applicable?
Windows Server 2022

- What is the architecture (x64, x86, ARM, ARM64)?
x64

### Other information

If you need more information, please let me know.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.