0
votes

I am using Bot Framework SDK v-4 and trying to use QnAMakerService.

I have the BotService.cs where I have the QnAMakerService instatiations. While, initiating the QnAMakerService I get an error in my Visual Studio Diagnostics window:

could not load type Microsoft.Bot.Builder.Internals.Fibers.SetField

Below is my code. I have commented the line where I get the error:

public BotServices(BotConfiguration botConfiguration)
{
    foreach (var service in botConfiguration.Services)
    {
        switch (service.Type)
        {
            case ServiceTypes.QnA:
                {
                    var qna = (Microsoft.Bot.Configuration.QnAMakerService)service;
                    if (qna == null)
                    {
                        throw new InvalidOperationException("The QnA service is not configured correctly in your '.bot' file.");
                    }

                    if (string.IsNullOrWhiteSpace(qna.KbId))
                    {
                        throw new InvalidOperationException("The QnA KnowledgeBaseId ('kbId') is required to run this sample. Please update your '.bot' file.");
                    }

                    if (string.IsNullOrWhiteSpace(qna.EndpointKey))
                    {
                        throw new InvalidOperationException("The QnA EndpointKey ('endpointKey') is required to run this sample. Please update your '.bot' file.");
                    }

                    if (string.IsNullOrWhiteSpace(qna.Hostname))
                    {
                        throw new InvalidOperationException("The QnA Host ('hostname') is required to run this sample. Please update your '.bot' file.");
                    }

                    string defaultMessage = "Sorry no answer found.";
                    QnAMakerAttribute qnAMakerAttribute = new QnAMakerAttribute(qna.EndpointKey, qna.KbId, defaultMessage, 40, 5, <end_point>);
                    var qnaMakerService = new Microsoft.Bot.Builder.CognitiveServices.QnAMaker.QnAMakerService(qnAMakerAttribute); // Error is here
                    qnaMakerServices.Add(qna.Name, qnaMakerService);
                    break;
                }
        }
    }
}

I had used native Http calls earlier with the same endpoint and it worked fine. Any idea what I am doing wrong?

1
you may have a mismatch in dependency versions. Check your Microsoft.Bot.*.dll versions and ensure they're all equalDaniel
@Daniel But I updated all the dependent nuget packages to the latest stable version. Shouldn't it work?Souvik Ghosh
a lot of things should work. I would still double checkDaniel
@Daniel You may be right. Out of all the other dlls this is the only one which is not having the same version. I will check more on this. Thanks!Souvik Ghosh

1 Answers

0
votes

@SouvikGhosh Daniel is correct, there's a mismatch in dependency versions going on here.

As you see in the Microsoft docs, the Fiber class applies to Microsoft.Bot.Builder v3.

What you need for QnAMaker in v4 is Microsoft.Bot.Builder.AI.QnA for C#: https://github.com/Microsoft/botbuilder-dotnet/tree/master/libraries/Microsoft.Bot.Builder.AI.QnA


TL;DR just make sure you have only v4 dependencies and not a mix of v3 and v4