gpt4 book ai didi

c# - Azure 队列 : Unable to read cloud queue messages. AsString 和 AsBytes 属性抛出 System.ArgumentException

转载 作者:行者123 更新时间:2023-12-03 05:35:36 24 4
gpt4 key购买 nike

好的,我有一个类旨在管理 Azure 云队列消息,插入工作正常:

    public async void Insert(string message)
{
await Queue.AddMessageAsync(new CloudQueueMessage(message));
}

请注意,此Queue是一个CloudQueue实例。

This is the message inserted in the storage using the above method

这是使用上述方法插入存储中的消息

但是,在尝试获取查看消息时,发生了奇怪的行为,我无法阅读任何内容:

The content of the message is throwing an exception and is being returned as null

消息内容引发异常并以 null 形式返回。

This is the messageCount value

这是messageCount值。

以下是用于检索消息的文本方法:

    public async Task<List<string>> GetMessages()
{
var list = new List<string>();

await Queue.FetchAttributesAsync();
int messageCount = Queue.ApproximateMessageCount ?? 0;

if (messageCount == 0) return list;

foreach (var msg in await Queue.GetMessagesAsync(messageCount))
{

list.Add(msg.AsString);
}

return list;
}

编辑:我按照批准的答案中的指示进行了检查,发现我使用的是一个已弃用的软件包,该软件包似乎不再起作用。 Deprecated package该库已被拆分为多个部分,并且已被弃用。

我必须使用最新的 API 并更改我的代码,它实际上更容易使用,但需要进行一定的返工。现在可以使用了,在这个新版本(.NET v12)中使用队列的方式是documented here .

最佳答案

我相信这与错误的(旧版)Nuget 包有关。我最近遇到了这样的问题,当我升级到以下软件包后,这个问题得到了解决:

Install-Package Microsoft.Azure.Storage.Common -Version 11.1.7
Install-Package Microsoft.Azure.Storage.Queue -Version 11.1.7

https://www.nuget.org/packages/Microsoft.Azure.Storage.Queue/

https://www.nuget.org/packages/Microsoft.Azure.Storage.Common/

关于c# - Azure 队列 : Unable to read cloud queue messages. AsString 和 AsBytes 属性抛出 System.ArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62918338/

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