gpt4 book ai didi

c# - Azure Storage Queue.AddMessageAsync(item,cancelToken) 缺少接受两个参数的方法

转载 作者:行者123 更新时间:2023-12-03 05:47:55 26 4
gpt4 key购买 nike

我正在尝试执行以下无法编译的代码:

var message = new CloudQueueMessage(item);
return queue.AddMessageAsync(message, cancellationToken);

编译器表示不存在只接受 2x 参数的方法。

The offical MS documentation应该有一个接受2x参数的方法。

The official code on GitHub还表明应该有一个接受 2x 参数的方法...

我通过 NuGet 使用 Assembly Microsoft.WindowsAzure.Storage, Version=9.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 ,其中仅列出了以下 3 种方法:

public virtual Task AddMessageAsync(CloudQueueMessage message);
public virtual Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken);
public virtual Task AddMessageAsync(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay, QueueRequestOptions options, OperationContext operationContext);

有人可以解释一下吗:

  1. 这些文档是否已经过时?
  2. 文档很好,但适用于较新版本的 Azure 存储 NuGet 包?
  3. 如果它不在 v 9.3 NuGet 包中,那么我应该如何正确地将 CancellationToken 传递给该方法?为每个参数传递null

这是针对 .NET Core 项目的。

最佳答案

.NET Framework 和 .NET Core 的存储 SDK 存在细微差别,文档中未对此进行说明。

从 v9.2.0 开始,.NET Core SDK 中已删除 AddMessageAsync(CloudQueueMessage message, CancellationToken CancellationToken) 方法。因此,一种解决方法是将 sdk 降级到 v9.1.1。

好消息是,这些差异将在下一版本的 Azure 存储包中消除。查看相关issue comment .

This library is set to target .NET Standard 2.0 and will not contain these minor API differences.

因此另一个解决方法是使用 preview version在它普遍可用之前。

请注意,预览版本中的命名空间已更改。

using Microsoft.Azure.Storage; 
using Microsoft.Azure.Storage.Queue;

关于c# - Azure Storage Queue.AddMessageAsync(item,cancelToken) 缺少接受两个参数的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51694834/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com