2017-05-02 2 views
1

PromptDialog.Choice를 활용하려고 할 때 잘못된 Type 예외가 발생합니다. 여기 내 대화 상자의부터 내 코드입니다 :PromptDialog.Choice - 잘못된 형식 예외

public async Task StartAsync(IDialogContext context) { 
    await context.PostAsync(ConversationHelper.CreateReschedulePromptMessage()); 
    context.Wait(MessageReceivedAsync); 
} 

public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result) { 
    var message = await result; 
    var Options = new[] { "Location", "Date and Time", "Both" }; 

    if (message.Text.ToUpper().CompareTo("PICKUP") == 0) { 
    _rescheduleType = "pickup"; 
    string prompt = string.Format("Is the {0} location incorrect, is the date and time incorrect, or both?", _rescheduleType); 
    PromptDialog.Choice(context, OnResumeFromRescheduleChoice, Options, prompt, promptStyle: PromptStyle.Auto, descriptions: Options); 
    } 
    else if (message.Text.ToUpper().CompareTo("DROP") == 0) { 
    _rescheduleType = "drop-off"; 
    string prompt = string.Format("Is the {0} location incorrect, is the date and time incorrect, or both?", _rescheduleType); 
    PromptDialog.Choice(context, OnResumeFromRescheduleChoice, Options, prompt, promptStyle: PromptStyle.Auto, descriptions: Options); 
    } 
    else { 
    await context.PostAsync(ConversationHelper.CreateGenericRescheduleMessage(SUPPORTNUMBER)); 
    } 

    context.Done<object>(null); 
} 

private async Task OnResumeFromRescheduleChoice(IDialogContext context, IAwaitable<string> result) { 
    var choice = await result; 
} 

OnResumeFromRescheduleChoice 방법은 발사되지만 ResumeAfter 위양이 유형의 문자열을 기대하지만, 객체를 수신하기 때문에 결과 쇼에 실패했습니다. PromptDialog의 잘못된 사용입니까? 또한 사용자에게 선택 사항이 프롬프트되지 않습니다. Bot.Builder 버전 3.5.5를 사용하고 있습니다.

+0

컨텍스트입니다. (null) 호출이 너무 일찍 발생 했습니까? –

답변

1

else 절 내에서 context.Done<object>(null); 호출을 이동하십시오. Prompt을 발사 한 후 으로 전화 할 수 없습니다.

+1

그건 내 문제 였어. 감사. –