【发布时间】:2017-04-01 05:32:59
【问题描述】:
我正在使用 Microsoft Bot Framework 使用 LuisDialog 创建一个非常简单的机器人。但是我不断收到 System.Collections.Generic.KeyNotFoundException。
这是我的控制器:
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
await Conversation.SendAsync(activity, () => new QuotesDialog());
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
这是我的对话:
[Serializable]
[LuisModel("MyModelIdGoesHere", "MySubscriptionKeyGoesHere")]
public class QuotesDialog : LuisDialog<object>
{
[LuisIntent("CheckQuote")]
public async Task CheckQuote(IDialogContext context, LuisResult result)
{
await context.PostAsync("Hello you!");
context.Wait(MessageReceived);
}
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
await context.PostAsync("I'm sorry. I didn't get that.");
context.Wait(MessageReceived);
}
}
如果我使用较旧版本的 Bot Framework,例如 3.0.0,我会收到以下错误: 500内部服务器错误 { "message": "发生错误。" }
但是,如果我更新到最新的稳定版本 (3.2.1),则会收到以下类型为“System.Collections.Generic.KeyNotFoundException”的错误:
“异常:System.Collections.Generic.KeyNotFoundException:给定的 字典中不存在密钥。在 System.Collections.Generic.Dictionary2.get_Item(TKey key) 在 Microsoft.Bot.Builder.Dialogs.LuisDialog"
完整的堆栈跟踪在这里:
我尝试在另一个解决方案上创建一个新项目,但我得到了同样的错误。我尝试通过 nuget 安装不同版本的 Bot Framework,但就像我之前所说的那样,无论如何我仍然会收到错误消息。到目前为止,我对 Bot Framework 的经验非常少,所以我真的不知道还能尝试什么。
【问题讨论】:
标签: c# generics botframework azure-language-understanding