c# - dc.BeginDialogAsync:“值不能为空。\n参数名称:选项”
问题描述
每次我运行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 { });
它现在有效。
推荐阅读
- c# - “IPhoneLine”不包含“PhoneLineStateChanged”的定义
- java - 使用 j2html 的登录表单示例
- java - java.lang.RuntimeException:命名空间“http://ws.abc.com/”的架构已经包含类型
- spring - 在 Spring Cloud Gateway 过滤器中引发自定义运行时异常
- html - 在相对定位的元素之前/之后对齐移动方向元素(上一个/下一个)(无 flexbox)
- java - 密码检查、验证和要求
- python - Windows Server上的Django MySQL连接错误
- python-3.x - 如何从另一个数据框中获取一个数据框中的公共列的值?
- ruby-on-rails - 无法在 Ruby on Rails 5 中显示数据库中的数据
- android - ExifInterface 返回错误的方向(因为它存储了多个冲突的属性)