我正在尝试使用 C# 保存机器人框架。我正在尝试将机器人状态保存到 azure blob 存储 使用 nuget 包
Microsoft.Bot.Builder.Azure.Blobs
版本 4.19.2。
我在 Startup.cs 文件中做的是
var storage = new BlobsStorage(
"connectionstring",
"containername"
);
var userState = new UserState(storage);
services.AddSingleton(userState);
var conversationState = new ConversationState(storage);
services.AddSingleton(conversationState);
但是我得到以下错误
System.InvalidOperationException:无法在“AllowedTypes”集合中找到以下类型。
请在自定义“JsonSerializerSettings”实例中提供“AllowedTypesSerializationBinder”,以及允许的类型列表。
例子:
new JsonSerializerSettings
{
SerializationBinder = new AllowedTypesSerializationBinder(
new List<Type>
{
typeof(PromptOptions),
typeof(DialogInstance),
typeof(DialogState),
}),
}
当我检查容器 blob 文件是否生成时
您可以在创建 BlobsStorage 实例时提供它:
new BlobsStorage(
"connectionString", "containerName", new Newtonsoft.Json.JsonSerializer
{
SerializationBinder = new AllowedTypesSerializationBinder(
new List<Type>
{
typeof(DialogInstance),
typeof(DialogState),
})
})