我正在上传图片并使用带有DownloadData的WebClient来获取字节数组,但是现在它引发了一个例外:
Exception: State size exceeded configured limit.
[File of type 'text/plain']
在使用完全相同的图像之前,我还没有注意到这种行为。可能出了什么问题?
private async Task SendPhoto_ActivityReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
Activity activity = await result as Activity;
Activity activityReply = activity.CreateReply();
if (0 < activity.Attachments?.Count)
{
if (activity.Attachments.FirstOrDefault().ContentType.Equals("image/jpg") ||
activity.Attachments.FirstOrDefault().ContentType.Equals("image/jpeg") ||
activity.Attachments.FirstOrDefault().ContentType.Equals("image/png") ||
activity.Attachments.FirstOrDefault().ContentType.Equals("image/tiff"))
{
picImage = activity.Attachments.FirstOrDefault().Name;
HttpClient httpClient= new HttpClient();
picImageFile = await httpClient.GetByteArrayAsync(activity.Attachments.FirstOrDefault().ContentUrl);
await context.PostAsync("Want to send another?");
context.Wait(SendAnotherImage_ActivityReceivedAsync);
}
}
}
更新:将WebClient更改为HttpClient.GetByteArrayAsync,问题仍然存在。 在PostAsync执行后立即在Bot仿真器中显示异常
答案 0 :(得分:0)
问题是picImageFile
是对话框内部的一个变量,因此对话框被序列化后会保存在状态中。两个选项