Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load file or assembly Microsoft.Extensions.DependencyInjection.Abstractions, Version=5.0.0.0 #3694

Closed
hkzenetex opened this issue Nov 16, 2020 · 4 comments

Comments

@hkzenetex
Copy link

hkzenetex commented Nov 16, 2020

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, #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>

20201120
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.

20201123
I found a related StackOverflow question, which links to issue Azure/azure-functions-vs-build-sdk #472 and finally to issue Azure/azure-functions-host #6893. @AartBluestoke summarized: "this can only be solved by upgrading azure functions to a newer version which has a dependency on the 5.x line of the abstractions."

@olakusibe
Copy link

olakusibe commented Nov 23, 2020

I am having similar issues, ihave explored same possible solutions and I am still stucked.

it seems Microsoft.Extension.Http and Microsoft.EntityframeworkCore Nuget are the problems, once removed the function app works

@BrennanConroy
Copy link
Member

Dupe of Azure/azure-functions-host#6893

TLDR; The functions host runs on ~3.1 and will host your app in-process dynamically. What this means is that if the functions host uses 3.1 of DependencyInjection.Abstractions, it will not be able to load 5.0 of the dll in-process for your app, and your app will fail to run.

@ghost
Copy link

ghost commented Nov 24, 2020

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Nov 24, 2020
@hkzenetex
Copy link
Author

hkzenetex commented Nov 25, 2020

To run my Azure Function project locally, I resolved missing assembly Microsoft.Extensions.DependencyInjection.Abstractions, Version=5.0.0.0 runtime error by referencing the old versions of all its dependent DLLs and by including multiple old versions of this assembly. However, I received errors from GitHub Workflow CI/CD when attempting deployment to Azure.

NU1605: Detected package downgrade

To deploy my Azure Function App, I resolved the NU1605 errors by including in the project file old versions of packages dependent on a common version of the original missing assembly, Microsoft.Extensions.DependencyInjection.Abstractions, and I specifically included the common older versions, 3.1.7 and 3.1.2.

<ItemGroup>
<!--<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />-->
<!--<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />-->
<!--<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />-->
<!--<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />-->
<!--<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="5.0.0" />-->
<!--<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />-->
<!--<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="5.0.0" />-->	  
  <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.7" />
  <PackageReference Include="Microsoft.Extensions.Http" Version="3.1.2" />	  
  <PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.7" />
  <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.7" />
  <PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="3.1.7" />
  <PackageReference Include="Microsoft.Extensions.Options" Version="3.1.7" /> 	  
  <PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="3.1.2" /> 
</ItemGroup>
<ItemGroup>
  <Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.2">    
     <HintPath>..\..\..\..\.nuget\packages\microsoft.extensions.dependencyinjection.abstractions
          \3.1.2\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
  </Reference>
</ItemGroup>

@ghost ghost locked as resolved and limited conversation to collaborators Dec 25, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants