BOTS Framework,无法加密 Null 属性

BOTS Framework, Null properties cannot be encrypted

今天我的 BOT 突然开始失败并出现此异常:

Null properties cannot be encrypted. Please assign a default value to the property if you wish to encrypt it.

尝试设置对话数据时发生错误,这是堆栈跟踪:

    at Microsoft.Bot.Connector.ErrorHandling.<HandleErrorAsync>d__2`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Connector.BotStateExtensions.<SetConversationDataAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.ConnectorStore.<Microsoft-Bot-Builder-Dialogs-Internals-IBotDataStore<Microsoft-Bot-Connector-BotData>-SaveAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.CachingBotDataStore.<Save>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.CachingBotDataStore.<Microsoft-Bot-Builder-Dialogs-Internals-IBotDataStore<Microsoft-Bot-Connector-BotData>-FlushAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.BotDataBase`1.<FlushAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.DialogTaskManagerBotDataLoader.<FlushAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.ExceptionTranslationDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.SerializeByConversation.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.PostUnhandledExceptionToUser.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at Microsoft.Bot.Builder.Dialogs.Internals.PostUnhandledExceptionToUser.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.LogPostToBot.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Conversation.<SendAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Conversation.<SendAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
    at TransAlta.Trading.Bot.Controllers.MessagesController.<Post>d__0.MoveNext() in C:\Users\acodallo\Documents\Bots\TradingBot\TradingBot\Controllers\MessagesController.cs:line 28

由于我没有更改代码并且我今天早上使用它没有问题,所以我不太确定会发生什么。任何帮助将不胜感激。

更新:

1) 在 dev.botframework.com 上使用模拟器或测试网络聊天客户端时,我没有看到此错误,仅在使用 Teams 时 2) 大多数逻辑存在于我的 LUIS 对话框和其他根据意图启动的特定对话框中:

[LuisIntent("Power.Buy")]
public async Task PowerTrade(IDialogContext context, IAwaitable<IMessageActivity>activity, LuisResult result)
{            
  BaseTrade formState = BaseTrade.InitState(result);
  formState.PositionType = PositionType.Buy;           

  SetCommonFields(formState);

  var tradeFormDialog = new FormDialog<BaseTrade>(formState, _tradeCreationDelegate, FormOptions.PromptInStart);            
  context.Call(tradeFormDialog, TradeTypeSpecificsDialog);
}

BaseTrade 模型:

public enum PositionType
{
    Buy, Sell, Swap              
}

public enum Unit
{
    Mw,
    Mwh,
    Gj,
    Mmbtu
}
public enum Timezone
{
    APT = 1,
    AST,
    CPT,
    CST,
    EPT,
    EST,
    GMT,
    MPT,
    MST,
    PPT,
    PST
}

[Serializable]
public class BaseTrade
{

    [Prompt("Position Type?")]
    public PositionType? PositionType;

    [Prompt("Who is the counterparty?")]
    public string Counterparty;         

    [Prompt("Start date?")]
    public DateTime StartDate;

    [Prompt("End date?")]
    public DateTime EndDate;

    public Timezone Timezone;

    [Prompt("Please enter the trade quantity")]
    public int? Quantity;

    public Unit? Unit;

    [Prompt("Price?")]
    public int? Price;

    public DateTime? TradeDate = new DateTime();

    public static IForm<BaseTrade> BuildForm()
    {
        return new FormBuilder<BaseTrade>().Message("OK, we are going to create a trade").Build();
    }

原来是微软这边的问题