Reputation: 215
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 :
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>
Upvotes: 0
Views: 1985
Reputation: 7347
As I have mentioned in the Comments this type of issue arise because of the same package installed with two different versions (Version Conflict).
Example:
When you have installed Serilog.AspNetCore
, the package Microsoft.Extensions.Logging.Abstractions
is included in the Microsoft.Extensions.Logging
.
When I check my bin/debug folder there is no Microsoft.Extensions.Logging.Abstractions.dll.
As Microsoft.Extensions.Logging.Abstractions
is under Serilog.AspNetCore
, it will not be available in the bin folder.
Initially even Iam unable to find the package in bin
.
You might have installed the same package again with another version.
How can force the dll build ?
This can be done in either of the below way:
Either by installing the latest version in VS Local, build and re-deploying the app.
OR
By copying the required version directly in wwwroot
folder (which you have already done and worked for you).
Upvotes: 1