【问题标题】:Azure - Error CS0433: The type 'IAsyncDisposable' exists in both 'Microsoft.Bcl.AsyncInterfaces,Azure - 错误 CS0433:“IAsyncDisposable”类型存在于“Microsoft.Bcl.AsyncInterfaces”中,
【发布时间】:2021-03-09 06:32:23
【问题描述】:

我已将 IAsyncDisposable 接口添加到我的项目的一个类中。 使用 Visual Studio 时一切正常。我可以编译和执行应用程序而不会出现任何错误或警告。

但是在将项目提交到 Azure 并在那里编译后,我收到以下错误:

##[error]..Web\Services\HubEventService.cs(13,41): 错误 CS0433: 类型 'IAsyncDisposable' 存在于两个 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' D:\a\1\s...Web\Services\HubEventService.cs(13,41): 错误 CS0433: 类型 'IAsyncDisposable' 存在于两个 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=中性,PublicKeyToken=cc7b13ffcd2ddd51' 和'System.Runtime,版本=4.2.2.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a' [D:\a\1\s....Web\Services....Web.Services. csproj] 完成构建项目“D:\a\1\s....Web\Services....Web.Services.csproj”(默认目标)——失败。 完成构建项目“D:\a\1\s....Web\Client....Web.Client.csproj”(默认目标)——失败。 完成构建项目“D:\a\1\s....Web....Web.sln”(默认目标)——失败。

我修改的代码如下:

    public class HubConnectionService : IAsyncDisposable
{ 
... 

public async ValueTask DisposeAsync()
        {
            if (HubConnection != null)
            {
                await HubConnection.DisposeAsync();
                HubConnection = null;
            }                
        }
}

有什么想法吗?

谢谢。

【问题讨论】:

    标签: c# .net azure


    【解决方案1】:

    here 所述,您需要在管道中使用更新版本的 NuGet。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 2011-05-18
      相关资源
      最近更新 更多