[英]dc.BeginDialogAsync: “Value cannot be null.\nParameter name: options”
每次我跑await dc.BeginDialogAsync("sign-in");
我得到這個例外是沒有意義的,因為其余參數是可選的。 這讓我非常困惑。 這是我的代碼:
public FlexoBot(ConversationState conversationState)
{
this.dialogState = conversationState.CreateProperty<DialogState>("dialog-state");
this.dialogs = new DialogSet(this.dialogState);
// Make oauth card available to use for all handlers
this.dialogs.Add(new OAuthPrompt("oauth", new OAuthPromptSettings() { ConnectionName = "flexo-auth" }));
dialogs.Add(new WaterfallDialog("sign-in", new WaterfallStep[] {
PromptSignIn,
GreetUser,
}));
}
protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
{
var dc = await this.dialogs.CreateContextAsync(turnContext);
foreach (var member in membersAdded)
{
if (member.Id != turnContext.Activity.Recipient.Id)
{
await dc.BeginDialogAsync("sign-in");
// Throws: System.ArgumentNullException has been thrown "Value cannot be null.\nParameter name: options"
}
}
}
我終於弄明白了。 這是因為我正在調用return step.PromptAsync("oauth", null);
在我的一個瀑布步驟。 我改成了:
return step.PromptAsync("oauth", new PromptOptions { });
它現在有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.