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):
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.
Microsoft.Extensions.DependencyInjection.Abstractions, Version=5.0.0.0
- Looks like you are referring some parent nuget packages meant for .net 5 which depends on this. At the time of this writing, Azure Function does not yet support .net 5 (so quite possible see such issue from a forced v5 nuget reference as Function host works a bit differently than a regular asp.net core app) UPDATE: Now supported. Track this for future update. So, when needed, use only the 3.1.x latest version (not 5 yet) of any relevant nugets like Microsoft.Extensions.*
or Microsoft.AspNetCore.*
.
N.B. Ideally you should not require any of those packages explicitly in Function though unless you need to do something special.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With