After upgrading a project from 2020 to 2021, one of my packages is throwing this error :
The type ‘IAsyncDisposable’ exists in both ‘Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ and ‘netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’
I did find this post around a similar issue [Unity] How to solve ambiguous reference with extern alias? ($2349444) · Snippets · GitLab , but I’m not sure how to apply it (the screenshots are gone) , or if I even can, since it is a package… This is super frustrating, because I have to upgrade to 2021 for another package to work. If anyone could help, I’d be super grateful.
But the error essentially tells you the opposite. You have two (or more) assemblies in your project which contain the same namespace / types / classes. The error especifically is mentioning the IAsyncDisposable interface which is defined in the “Microsoft.Bcl.AsyncInterfaces” assembly as well as the “netstandard” assembly. So one has to go. Since “netstandard” is essentially the basis of C#, it’s the “Microsoft.Bcl.AsyncInterfaces” assembly that should probably be gone.
Maybe you imported several packages which aren’t compatible with .NET standard?
The thing is I did not import any package apart from the one that is causing the issue. It works in Unity 2020, but not in 2021. So I just searched for "“Microsoft.Bcl.AsyncInterfaces” and deleted the .dll. It did fix the error, maybe that was all ? I’m a bit confused by why this was imported if it’s not needed, but I’ll see if I get some bugs…