I have an app running on azure. I have recently updated it to .NET 7 but the deploy always works fine. Yesterday I deployed the app without changing or adding a dependency and I got this exception.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. File name: 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' at Microsoft.Extensions.DependencyInjection.LoggingServiceCollectionExtensions.AddLogging(IServiceCollection services, Action`1 configure) at
When I run the project locally it starts without an error. I have tried to add the missing dependency but this does not fix the error.
I have also checked the wwwroot folder on azure but the dll is there
What I have tried :
- Add the missing .dll
- Delete .vs, bin and obj folder
- Tried to change the version suggested here Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions
Is there anything I have missed to change it? Any help is welcome.
Update:
As Harshitha suggest in the comments I have also the following lines to the .csproj and to my webconfig. But it does not help
.csproj
<ItemGroup>
<Content Include="packages\microsoft.extensions.logging.abstractions\7.0.0\.signature.p7s" />
<Content Include="packages\microsoft.extensions.logging.abstractions\7.0.0\microsoft.extensions.logging.abstractions.7.0.0.nupkg" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" Culture="neutral" PublicKeyToken="adb9793829ddae60" processorArchitecture="MSIL">
<HintPath>packages\microsoft.extensions.logging.abstractions\7.0.0\lib\net7.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
</ItemGroup>
web.config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>