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
Microsoft.Bcl.AsyncInterfaces missing for netcoreapp3.1 #823
Comments
Crap! I'm able to reproduce this issue. Not sure yet what goes wrong here. The NuGet references MS.Bcl.AsyncInterfaces in the 4.6.1 and .NETStandard2.0 targets. The reference is omitted in .NETStandard2.1 because the interface is part of .NETStandard2.1. But perhaps the version compiled for 2.1 contains a hard-referenece to MS.Bcl.AsyncInterfaces. I wil investigate and push a patch release. In the meantime, you can work around the issue by adding MS.Bcl.AsyncInterfaces to your project as NuGet package. |
Problem found: the /lib/netstandard2.1/SimpleInjector.dll was missing from the NuGet package. This caused NuGet to revert to the /lib/netstandard2.0/SimpleInjector.dll, while still using the .NET Standard 2.1 configuration, which didn't include Microsoft.Bcl.AsyncInterfaces. I pushed Simple Injector 5.0.1 to NuGet that fixes this problem. |
Hi, Build 5.01 (upgraded from build 4.1) broke my application (this took several days to find what was going on, as did not suspect simple injector). And adding a ref to nuget for this assembly does not work (I did not try an assembly redirect, and i believe i turned off this option). It looks like Simple Injector contains a reference to 1.0.0 for Microsoft.Bcl.AsyncInterfaces I believe the solution is to use version 1.1.0 or 1.1.1 via nuget, as quite a few libraries do (such as csv helper, reactive, etc) within your library, instead of including a gac assembly in your library. Downgrading back to simple injector 4.1 fixed the problem Several other libraries which are using version 1.1.0 work fine. |
Hi Michael, A NuGet package should always use the lowest possible version of a dependency, which is why Simple Injector referwnces 1.0 of AsyncInterdaces. This generally means that binding redirects need to be used (under .NET) and NuGet typically managescthat for you. I say typically, because NuGet tends to fuck up from time to time. But the solution is to manually add the binding redirect in case NuGet fails to do so. |
That’s true, except in this case.
It started with value.tuples and the nightmare of conflicting namespaces and version conflicts, when moving from net 4.6.x to 4.7.2
Placing a redirect in the app.config worked some of the time. The best was not to have a nugget package and use the latest framework. Yet, some libraries wanted the nugget package. Microsoft tried to fix this with magic under the covers, but sometimes it did not work, and some areas were not aware of the magic. It was fragile when using VS package installer. One of the solutions included turning off package redirects for desktop apps.
In this case ver 1.0.0 is a framework file. I am not sure if you are including the actual assembly in the package, but the error makes it sound like that?
I traced how the manifest was being created for 4 different public libraries using bcl .asyncinterfaces, and simple injector was the one with the 1.0.0 ref, and caused the problems, which resolved when deleting the bin and obj folders and rebuilding with a version of simple injector wo this assembly.
Try changing it to ver 1.1
Great product, and thank you for all of your work.
Michael
|
No, no other dlls are included except the SimpleInjector.dll itself. The only thing the SimpleInjector.nupkg does is reference the other Nuget packages. I'm very sorry you are running into this. It is for this exact reason that the Simple Injector core library never had any dependencies. You quickly run into binding redirect issues, and NuGet often fails to generate correct binding redirects for you. Unfortunately, with The new IAsyncDisposable, there is no good way around this. You will have to add the binding redirect. Upgrading the package dependency might fix the problem for you, but is only a transient fix, because it will still cause problems for others and when never versions of AsyncInterfaces is pushed, as long as you don't use binding redirects under .NET Framework. |
Hi Steven, I will circle around to this in a couple days, by creating a small test app, and see what works or not. Including what happens when another library is present that is referencing version 1.1+ of Microsoft.BCL.AsyncInterfaces, along with Simple Injector 5.01 As well as revisit using an assembly redirection Again, where it fails, is after installing the app with Microsoft Visual Studio Package Installer (upon startup), not after F5 build. So will test in that environment, to confirm the behavior in a limited small app. On another note, you may want to contact the developers of the following libraries, to learn from their approach. All of these use Microsoft.BCL.AsyncInterfaces Ver 1.1.0
Thanks, and will let you know if I find anything of value. |
You can add the following binding redirect to fix the problem: <?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity
name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-{your-version}" newVersion="{your-version}"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity
name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-{your-version}" newVersion="{your-version}"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> Where
|
Follow up: Apparently, binding redirects does not exist on Azure functions! But the solution presented in this article seems to work for me: https://www.thewissen.io/azure-functions-binding-redirects/ |
Hello, I'm having the same issue with .net core 3.1.10. |
@AceVentura this update should help. You likely need to add both AsyncInterfaces and and System.Threading.Tasks.Extensions to your binding redirects (and possibly even System.Runtime.CompilerServices.Unsafe). |
@dotnetjunkie I'm on .net core. As far as I know, there are no such thing as binding redirects here.. |
@AceVenture. Yes, what I understood is that binding redirects are not an issue any longer on .NET Core. So, what isnyoyr issue exactly? Do you have an exception message with stack trace? A bit more information would be helpful. |
@dotnetjunkie the error happens when I call this: IServiceProvider provider =
SimpleInjectorServiceCollectionExtensions.AddSimpleInjector(services, _container).
BuildServiceProvider(validateScopes: true); Exception+ Stack Trace:
Note: This only happens in the xunit project. The WebApi project is working without issues. |
That's because the dependency with the Microsoft.Bcl.AsyncInterfaces NuGet package was added in Simple Injector v5. The Simple Injector v4 core library does not have any dependencies. Did you try adding the Microsoft.Bcl.AsyncInterfaces explicitly to your xunit project? |
I have not, because the package says it's not needed: |
Would you mind trying it anyway? We're in NuGet land here. Things get murky sometimes. Also, can you check at runtime, which assemblies (exact version number) the following types live in:
You can do this, for instance, by adding a unit test that does the following: Assert.Fail(typeof(IAsyncDisposable).Assembly.FullName + " " +
typeof(ValueTask).Assembly.FullName); |
@dotnetjunkie with the package it does work yes. |
I have had this myself with other packages in the past, so I know that adding packages to the startup project (in your case the xunit project) helps. Don't ask me why, though. Not sure what's going on under the covers. That said, the addition of the AsyncInterfaces assembly to the core library gave a lot of trouble. Unfortunately, as I discussed in #867, I haven't found a good way to circumvent these issues. |
As I suggestion, I would put a warning somewhere in the documentation about this error. Or worst case scenario, make it a required dependency. |
The dependency is already required. Nothing we can do in that respect. |
Maybe increase it to the V5? (It's the one I installed). That may be the culprit |
That will unfortunately not work, because a dependency on v5 might cause problems with users of .NET Core v3, and even if it works, it will only temporary solve the problem, untill the moment that Microsoft comes with newer versions of these packages. In that case, the dependency hell starts all over again. |
Hi @AbeniMatteo, @andrejohansson, @AceVentura, I pushed an 5.2.0-alpha2 version of the Simple Injector core library and the ASP.NET Core integration packages to NuGet. These set of packages tend to solve the problems regarding You can see more details about what changes here: #867. This is also the place to post any feedback. Thanks in advance |
Hey @dotnetjunkie, I only managed to test it today. Removed Microsoft.bcl.AsyncInterfaces and tested with 5.2.0-alpha2 and 5.2.0. The error is the same as before. |
@AceVentura, that's very unfortunate. Fortunately, Simple Injector is not part of the Diamond Dependency Conflict any longer. Please review your solution's dependency chains. Your application is likely using multiple packages that reference different versions of either:
Here are some packages that I know take a dependency on one of the above:
See if you can either remove those packages. In some cases (e.g. with Microsoft.AspNetCore.Mvc.Core or Microsoft.AspNetCore.Mvc.Core) you will certainly be stuck with those dependencies and there's not much you can do about it. Instead, you can try the following:
I hope this helps. |
I confirm this issue solved by updated SimpleInjector.Integration.AspNetCore.Mvc to 5.2.0-alpha2. |
Thanks for the feedback @Lukiya, much appreciated. |
@dotnetjunkie |
@AbeniMatteo, awesome. Thanks |
Hi i have the same problem in my razor pages project in net5.0. Approximately when will the alpha package be released as a stable version? |
Approximately 44 days ago. |
Sorry I didn't see it because I directly installed SimpleInjector.Integration.AspNetCore.Mvc 5.1.1 which doesn't depend on the new version. Sorry |
No problem @pampua84. If you upgrade to SimpleInjector.Integration.AspNetCore.Mvc 5.2, you'll get SimpleInjector-5.2 as well. But I advise you to explicily install the Simple Injector core library as well in your project and upgrade that to 5.2.1, as it contains an important bug fix. |
Heya, just updated my ASP.NET Web API project .NET 5, and I see this issue. I try to use version 5.2.0 but seems https://www.nuget.org/packages/SimpleInjector.Integration.AspNetCore.Mvc in nuget is still at v5.1.1 :) Although good things, this makes me realize that I dont use Razor pages so I use https://www.nuget.org/packages/SimpleInjector.Integration.AspNetCore.Mvc.Core instead. Thanks! |
Hi @gedeh , thank you for reporting this. Something apparently went silently wrong during uploading the packages. Either at my side, or at NuGet's side. I'll try to upload the missing packages a.s.a.p. |
@gedeh, the package is now waiting to be indexed by Nuget. Will be available soon. |
That was blazing fast @dotnetjunkie! See it in NuGet now, wow! |
I'm having this issue with .NET 5, I use Autofac |
@vutung3196, this is the Simple Injector forum. We will not answer questions related to Autofac. |
Yeah I see |
I know it's been more than a year since last answer, but.... I wanted to say something that could help and it's that, apparently, the order in which the Hope it helps. |
Version
5.0.0
Expected behavior
No expection.
Actual behavior
Exception thrown:
To Reproduce
repro.csproj
program.cs
Additional context
For .NET Core apps, IAsyncDisposable is declared in System.Runtime.dll and Microsoft.Bcl.AsyncInterfaces is also not listed as a Nuget package dependency.
The text was updated successfully, but these errors were encountered: