简体   繁体   中英

AIMLbot Input string was not in a correct format. C#

I try to make an artificial engine with AIMLbot in C#, but when I say the first word the program breaks and I get the following error:

Exception User-Unhandled System.FormatException: 'Input string was not in a correct format'

at the line

Result result = bot.Chat(request);

The code with the error:

private void Rec(object s, SpeechRecognizedEventArgs e)
{
    string speech = e.Result.Text;
    //richTextBox1.Text = "You: " + speech + Environment.Newline;

    richTextBox1.AppendText("You: " + speech + Environment.Newline);
    Request request = new Request(speech, user, bot);
    Result result = bot.Chat(request);

    richTextBox1.AppendText("AIDA" + result.RawOutput + Environment.Newline + Environment.Newline);
}

I really need some help :))

Your error

Input string was not in a correct format

Tells you that you have something expecting a string but you are not passing it in a string. The exact line that this is failing on tells you that it is

request

that is not a string when you are passing into bot.Chat(request)

You have declared it as a Request thus it is not a string, however it may be null so if you put a break point on that line, debug and step through the code you can inspect the value of request and see what it is.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM