skip to Main Content

i am trying to save bot framework using C#. I am trying to save bot state to azure blob storage
using nuget package Microsoft.Bot.Builder.Azure.Blobs version 4.19.2.
What i am doing is in Startup.cs file is

 var storage = new BlobsStorage(
                "connectionstring",
                "containername"
                );

 var userState = new UserState(storage);
            services.AddSingleton(userState);


var conversationState = new ConversationState(storage);
            services.AddSingleton(conversationState);

But i am getting following error

System.InvalidOperationException: Unable to find the following types in the ‘AllowedTypes’ collection.

Please provide the ‘AllowedTypesSerializationBinder’ in the custom ‘JsonSerializerSettings’ instance, with the list of types to allow.

Example:

new JsonSerializerSettings
{
    SerializationBinder = new AllowedTypesSerializationBinder(
        new List<Type>
        {
            typeof(PromptOptions),
            typeof(DialogInstance),
            typeof(DialogState),
        }),
}

When i check container blob files are generated anyways

2

Answers


  1. You can supply this when you create the BlobsStorage instance:

        new BlobsStorage(
        "connectionString", "containerName", new Newtonsoft.Json.JsonSerializer
                {
                    SerializationBinder = new AllowedTypesSerializationBinder(
                        new List<Type>
                        {
                            typeof(DialogInstance),
                            typeof(DialogState),
                        })
                })
    
    Login or Signup to reply.
  2. This issue was patched in v4.19.3.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search