【问题标题】:LuisResult.Entities.Add causes a System.NotSupportedExceptionLuisResult.Entities.Add 导致 System.NotSupportedException
【发布时间】:2017-07-20 14:22:56
【问题描述】:

在我的代码中,我像这样动态地将实体添加到 Luis Result:

[LuisIntent("Show Color")]
public async Task displayColor(IDialogContext context, LuisResult result)
{ 
    EntityRecommendation color;
    if (!result.TryFindEntity("color", out color)) {
        color = new EntityRecommendation();
        color.Entity = "white";
        color.Type = "color";
        result.Entities.Add(color); // <-- This Line Causes the Exception
    }
}

奇怪的是这段代码以前可以工作,但现在已经停止工作,现在当result.Entities.Add(color); 行被命中时,机器人模拟器中会显示这个异常:

这是 Visual Studio 2015 中显示的异常:

这可能与错误的 Nuget 包版本有关吗?它之前运行顺利,但我添加了一些身份验证服务,现在出现了这个异常。感谢您的帮助。

【问题讨论】:

  • 嗨,Megan,您是否已经尝试删除身份验证服务并一次添加一项,直到找到罪魁祸首/原因?
  • @JasonSowers 是的!我现在正在运行没有身份验证服务的机器人

标签: c# .net exception botframework azure-language-understanding


【解决方案1】:

有人在BotBuilder repo 上为我回答了这个问题

来自用户@ashicertis 我相信您需要将实体对象提取到一个新的 变量,然后进行更改。

var entities = new List(result.Entities);
entities.Add(new EntityRecommendation());

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-02
    • 2015-09-09
    • 1970-01-01
    • 2016-08-21
    • 2015-07-24
    • 2020-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多