-
Notifications
You must be signed in to change notification settings - Fork 763
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
Azure functions dependency injection - error when referencing class library #1718
Comments
I created a repro here: https://github.com/joseftw/azure-functions-di-bug |
Just a guess, can you mix your class library which is referencing Microsoft.Extensions.DependencyInjection.Abstractions 3.0.0-preview5.19227.9 with Azure Function netcoreapp2.1? |
I remember that I had a similar problem, when referencing I tried with your repro you posted, and I got the same error your describe, but resolved it by removing the direct reference to |
Thanks @MikaBerglund. To me it feels like a bug, the Microsoft.Extensions.DependencyInjection.Abstractions package was created specifically for this scenario, to have one common abstraction. What do you think? :) |
Sure it feels like a bug, or at least an unwanted feature. At the end of the day, the |
Is that true? Looking at the sample, the class library references This kind of |
Transferring to DI repo and area. |
The class library references version So for both projects the same version of |
That's not what the package manifest itself says: https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection If you're looking in Visual Studio, it shows the resolved version, not the version specified in the dependency. When you have two package references in the dependency graph for the same ID, only one version is selected (the highest one generally) and used to satisfy both dependencies. This is generally good, but can lead to situations like this where you are referencing a 3.0 package with a breaking change and a dependency is built against the 2.2 package without that breaking change thus causing a break. You should avoid crossing the version "streams" when referencing dependencies like this as breaking changes can bite you. Does the issue occur if you change your class library to depend on |
OK. I was under the wrong impression then. |
Closing as it appears there is no actionable work here. It is possible to use the Abstractions library in this way, but you should generally stick the the lowest version supported on your platform to avoid these issues. There are cases where using a higher version will work, but your code may be built expecting certain methods/members to exist that don't. |
✔️ Had the same issue. Just to clarify how to fix it for anyone who would get that out of the box following the instructions on DI with .net Functions - downgrade version of nuget package Microsoft.Extensions.DependencyInjection from 3.0.0 to 2.2.0 |
Worked for me after downgrading it in a class library as well |
This worked for me too ! Thanks !! |
I have a Azure Functions project that has a reference to a class library (netstandard 2.0).
The class library contains a reference to Microsoft.Extensions.DependencyInjection.Abstractions.
The class library has the following extension method:
My functions startup looks like this:
Startup.cs
When the Azure Functions project references the class library, the following error occurs:
If I remove the reference to the class library, the function app starts as expected.
So the problem appears to be that im using the Microsoft.Extensions.DependencyInjection.Abstractions package in my class library.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The functions project starts without any issues.
Additional context
The text was updated successfully, but these errors were encountered: