Cannot convert from 'method group' to 'ResumeAfter<object>'
Asked Answered
C

1

5

I'm trying to create a child dialog from a Luis intent to gather additional information from the user. However I'm receiving a Cannot convert from 'method group' to 'ResumeAfter<object>' error message on the second argument of context.Call

[LuisIntent("Login")]
public async Task LoginIntent(IDialogContext context, LuisResult result)
{
    var serverdialog = new ServerDialog();
    await context.Call(serverdialog, ResumeAfterServerDialog); //error here
}

private async Task ResumeAfterServerDialog(IDialogContext context, IAwaitable<string> serverName)
{
    this.serverAddress = await serverName;
    await context.PostAsync($"you've entered {this.serverAddress}");
    context.Wait(MessageReceived);
}

The server dialog class is

[Serializable]
public class ServerDialog : IDialog<object>
{
    public async Task StartAsync(IDialogContext context)
    {
        await context.PostAsync("Enter your server's name (example: 10.10.10.52)");
        context.Wait(ReceiveServerDialog);
    }

    public async Task ReceiveServerDialog(IDialogContext context, IAwaitable<IMessageActivity> result)
    {
        IMessageActivity message = await result;
        context.Done(message.Text);

    }
}

I found an explanation saying :

the type of the second parameter for MessageReceived is likely IAwaitable, but you need a method with a second parameter of IAwaitable, for example, if you're passing null as the result value and the type of your child dialog is IDialog.

however I couldn't make sense of this.

Calabrese answered 21/4, 2017 at 19:5 Comment(0)
M
13

Your dialog implements IDialog<object> but your ResumeAfter<T> method ReceiveServerDialog is a expecting a string (in IAwaitable<string> serverName parameter)

Change your dialog to implement IDialog<string> or change your ReceiveServerDialog method to be

private async Task ResumeAfterServerDialog(IDialogContext context, IAwaitable<object> serverName)
Mesdames answered 21/4, 2017 at 19:17 Comment(2)
I realized that just as soon as you posted this was the proper fix thank youCalabrese
took me days to figure this outBullshit

© 2022 - 2024 — McMap. All rights reserved.