Igo*_* Be 10 c# .net-standard .net-standard-2.0 .net-5
我有一个由 net5.0 应用程序使用的 netstandard2.0 库 该库使用的包之一引用了 Microsoft.Bcl.AsyncInterfaces 5.0.0 但我对每个应用程序都收到此警告:
47>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2203,5):
warning MSB3277: Found conflicts between different versions of "Microsoft.Bcl.AsyncInterfaces" that could not be resolved.
There was a conflict between "Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
"Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was chosen because it was primary and "Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was not.
References which depend on "Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll].
C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll
Project file item includes which caused reference "C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll".
C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll
References which depend on "Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [].
Run Code Online (Sandbox Code Playgroud)
请注意,“项目文件项包含引起的引用”不是项目,而是 dll 本身。我的猜测是 .net 标准编译器使用 1.0.0 版本来提供一些核心异步功能但是我怎样才能摆脱这个消息呢?.Net 5.0 似乎没有绑定重定向
我刚刚遇到了同样的问题,可以追溯到IAsyncDisposable资源的包含。
IAsyncDisposable我通过手动处理任何资源而不是使用符号解决了该问题await using ...。
前任。:
public async Task MyFunction()
{
await using var disposableResource = _factory.GetMyDisposableResource();
// rest of code.
}
Run Code Online (Sandbox Code Playgroud)
到
public async Task MyFunction()
{
MyDisposableResource disposableResource = default!;
try
{
disposableResource = _factory.GetMyDisposableResource();
//rest of code
}
finally
{
if(disposableResource is not null)
await disposableResource.DisposeAsync().ConfigureAwait(false);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1577 次 |
| 最近记录: |