In my azure function app project, I receive an assembly not found runtime error Microsoft.Extensions.DependencyInjection.Abstractions, Version=5.0.0.0. However, the assembly is included in multiple packages I installed from NuGet.
Visual Studio: 2019 Target Framework: netcoreapp3.1 Azure Functions Version: v3
Installed packages containing Microsoft.Extensions.DependencyInjection.Abstractions (5.0.0):
- Microsoft.Extensions.Http (5.0.0)
- Microsoft.Extensions.Logging (5.0.0)
- Microsoft.Extensions.Logging.EventSource (5.0.0)
Error: A host error has occurred during startup operation... Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Ineffective fix attempts: Installed Microsoft.Extensions.DependencyInjection.Abstractions (5.0.0) from NuGet, but error persists.
Following a similar issue, Microsoft.Extensions #2931, and StackOverflow question, I added to the project file the following.
<PropertyGroup> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> </PropertyGroup>
I also followed an article suggestion. After installing Microsoft.Azure.Functions.Extensions, the error persists.
I also followed another suggestion, and I added the following to my project file. However, the error persists.
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions"
publicKeyToken="adb9793829ddae60" culture="neutral" /> <bindingRedirect oldVersion="5.0.0.0"
newVersion="5.0.0" /> </dependentAssembly> </assemblyBinding> </runtime>
I attempted the workaround suggested in issue #401 of ASP.NET Core Announcements: reference the package for the assembly which is failing to load explicitly in my application. However, the error remains.
Using ILSpy, I found Microsoft.Azure.Functions.Extensions, which I installed from NuGet, references Microsoft.Extensions.DependencyInjection.Abstractions, Version 2.1.0.0.