2016-10-18 10 views
0

私はMicrosoft Bot Frameworkを使用して、LuisDialogを使用して本当にシンプルなボットを作成しています。しかし、私はSystem.Collections.Generic.KeyNotFoundExceptionを取得し続けます。ここでMicrosoft Bot Frameworkを使用した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); 
    } 
} 

私は3.0.0のように、ボットフレームワークの古いバージョンを使用している場合は、私は次のエラーを取得する: 500 InternalServerError { "メッセージ": "エラーが発生しました。 }

私は最新の安定版(3.2.1)にアップデートした場合しかし、その後、私はタイプ「System.Collections.Generic.KeyNotFoundException」の次のエラーを取得する:

"Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Microsoft.Bot.Builder.Dialogs.LuisDialog "

フルスタックトレースここにある:

http://pastebin.com/uLJF5fcV

私は別のソリューションに新しいプロジェクトを作成しようとしたが、私は同じエラーを取得します。私はボットフレームワークの異なるバージョンをナゲット経由でインストールしようとしましたが、前に述べたように、どちらか一方の方法でもエラーが発生します。これまでのボットフレームワークの経験はほとんどないので、他に何を試していいのか分かりません。

答えて

1

Noneメソッドの上に次のコードをもう一度追加できますか?

[LuisIntent("")] 

LuisDialogは、受信したメッセージに基づいて実行する方法(意図)を解決できない場合、あなたが見ているエラーは、通常、起こっています。

LuisDialogが空のインテントを探すときに問題が発生している可能性があります。hereと思われます。

handler = this.handlerByIntent[string.Empty]; 
+0

これはまさに正しいことであり、ドキュメントにも反映される必要があります。 – K48

関連する問題