ChoicePrompt not working on 4.6.X but 4.5.X works
See original GitHub issueVersion
4.6.2 4.6.1
Describe the bug
When the PromptAsync is executed on the waterfall conversation i get and error, this is my code:
private async Task<DialogTurnResult> ConsultarTecnologiaAsync (WaterfallStepContext step, CancellationToken cancellationToken) {
PromptOptions options = new PromptOptions () {
Prompt = step.Context.Activity.CreateReply ($"¿Con cuál servicio tienes duda?"),
Choices = new List<Choice> (),
Style = ListStyle.HeroCard
};
options.Choices.Add (new Choice () { Value = "PowerApps" });
options.Choices.Add (new Choice () { Value = "Teams" });
options.Choices.Add (new Choice () { Value = "OneDrive" });
options.Choices.Add (new Choice () { Value = "Flow" });
options.Choices.Add (new Choice () { Value = "Outlook" });
//in this line is where i get the error
return await step.PromptAsync ("consultar", options, cancellationToken);
}
I get this error after the PromptAsync is executed:
$exception {System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Recognizers.Text.Culture.MapToNearestLanguage(String cultureCode) at Microsoft.Bot.Builder.Dialogs.ChoicePrompt.OnPromptAsync(ITurnContext turnContext, IDictionary
2 state, PromptOptions options, Boolean isRetry, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\Prompts\ChoicePrompt.cs:line 126 at Microsoft.Bot.Builder.Dialogs.Prompt
1.BeginDialogAsync(DialogContext dc, Object options, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\Prompts\Prompt.cs:line 105 at Microsoft.Bot.Builder.Dialogs.DialogContext.BeginDialogAsync(String dialogId, Object options, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogContext.cs:line 170 at Microsoft.Bot.Builder.Dialogs.DialogContext.PromptAsync(String dialogId, PromptOptions options, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogContext.cs:line 198 at DoctorOffice365.Dialogs.Office365Dialog.ConsultarTecnologiaAsync(WaterfallStepContext step, CancellationToken cancellationToken) in C:\Users\bpalma\source\repos\DrOffice365\DrOffice365\Dialogs\Office365Dialog.cs:line 78} System.NullReferenceException`
Expected behavior
Show the prompt in the conversation, when the code is executed with 4.5.3 version it runs correctly
[bug]
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
@brunoslam The fix for this has been pushed to our 4.6.3 release, which should come out by Monday. I’m going to close this, but feel free to re-open if you see the same error in 4.6.3
Edit: Actually the C# 4.6.3 package just got pushed to Nuget.
Actually, there’s also a workaround if you want to stay with 4.6.2: You just need to specify a DefaultLocale when instantiating the ChoicePrompt:
new ChoicePrompt(nameof(ChoicePrompt)) { Style = ListStyle.SuggestedAction, DefaultLocale = "de-DE", }
Apparently that wasn’t necessary before. But if you add the DefaultLocale, it works also with the current version.