2017-07-20 25 views
0

在我的代碼動態添加實體到路易斯結果是這樣的:LuisResult.Entities.Add導致System.NotSupportedException

[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);被擊中:

Bot Emulator Exception

enter image description here

這裏是在Visual Studio 2015年顯示的異常:

enter image description here

難道這是關係到錯誤的NuGet包版本?它以前工作順利,但我添加了一些驗證服務,現在這個例外顯示。謝謝您的幫助。

+0

喜梅根你已經嘗試刪除認證服務,直到找到元兇/原因每次添加的東西呢? – JasonSowers

+0

@JasonSowers yup!我現在正在運行沒有授權服務的機器人 – Megan

回答

0

有人回答了這個問題,我在BotBuilder repo

從用戶@ashicertis 我相信,你需要提取實體對象轉換爲新的 變量,然後進行更改。

var entities = new List(result.Entities); 
entities.Add(new EntityRecommendation()); 
相關問題