无法加载类型 Microsoft.Bot.Builder.Internals.Fibers.SetField
Could not load type Microsoft.Bot.Builder.Internals.Fibers.SetField
我正在使用 Bot Framework SDK v-4 并尝试使用 QnAMakerService
。
我有 BotService.cs
我有 QnAMakerService
实例化。在启动 QnAMakerService
时,我的 Visual Studio 诊断 window:
出现错误
could not load type Microsoft.Bot.Builder.Internals.Fibers.SetField
下面是我的代码。我已经评论了我收到错误的行:
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;
}
}
}
}
我之前使用相同端点使用本机 Http
调用并且它工作正常。知道我做错了什么吗?
@SouvikGhosh Daniel 是正确的,这里的依赖版本不匹配。
如您在 Microsoft docs 中所见,Fiber
class 适用于 Microsoft.Bot.Builder v3
。
对于 v4 中的 QnAMaker
,您需要的是对于 C# 的 Microsoft.Bot.Builder.AI.QnA
:
https://github.com/Microsoft/botbuilder-dotnet/tree/master/libraries/Microsoft.Bot.Builder.AI.QnA
TL;DR 只需确保您只有 v4 依赖项,而不是 v3 和 v4 的混合
我正在使用 Bot Framework SDK v-4 并尝试使用 QnAMakerService
。
我有 BotService.cs
我有 QnAMakerService
实例化。在启动 QnAMakerService
时,我的 Visual Studio 诊断 window:
could not load type Microsoft.Bot.Builder.Internals.Fibers.SetField
下面是我的代码。我已经评论了我收到错误的行:
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;
}
}
}
}
我之前使用相同端点使用本机 Http
调用并且它工作正常。知道我做错了什么吗?
@SouvikGhosh Daniel 是正确的,这里的依赖版本不匹配。
如您在 Microsoft docs 中所见,Fiber
class 适用于 Microsoft.Bot.Builder v3
。
对于 v4 中的 QnAMaker
,您需要的是对于 C# 的 Microsoft.Bot.Builder.AI.QnA
:
https://github.com/Microsoft/botbuilder-dotnet/tree/master/libraries/Microsoft.Bot.Builder.AI.QnA
TL;DR 只需确保您只有 v4 依赖项,而不是 v3 和 v4 的混合