GithubHelp home page GithubHelp logo

Comments (5)

CXuesong avatar CXuesong commented on September 21, 2024

Did you see any exceptions bubbled up in the Output window of your VS debugger/activity log? Seems that Bot Builder resets the conversation if unhandled exceptions occurs.

from botbuilder.standard.

CXuesong avatar CXuesong commented on September 21, 2024

I've created a simple project containing your code, and it works well.

My suggestion is

  • try the PromptDialog in a class without LUIS in your project, and see whether it works.
  • as I've mentioned, note if there is any exception shown in the Output window when you see abnormal behavior

from botbuilder.standard.

mastermaq avatar mastermaq commented on September 21, 2024

Thank you for putting that together! That helped me figure out the issue. I don't remember why now, but I had the following in my Startup class (probably a copy/paste from one of the official samples):

public Startup(IConfiguration configuration)
{
    Configuration = configuration;

    RegisterBotModules();
}

private void RegisterBotModules()
{
    Conversation.UpdateContainer(builder =>
    {
        builder.RegisterModule(new ReflectionSurrogateModule());
    });
}

That registermodule line with the ReflectionSurrogateModule appears to be the culprit. If I comment out that code, it works just fine.

This is the exception thrown when the abnormal behavior occurs:

Exception on deserializing stored data! Stack has been cleared. Details: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Bot.Builder.Internals.Fibers.Serialization.StoreInstanceByFieldsSurrogate.System.Runtime.Serialization.ISerializationSurrogate.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
at Microsoft.Bot.Builder.Internals.Fibers.Serialization.SurrogateLogDecorator.System.Runtime.Serialization.ISerializationSurrogate.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(BinaryParser serParser, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, Boolean check)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
at Microsoft.Bot.Builder.Internals.Fibers.FormatterStore1.Microsoft.Bot.Builder.Internals.Fibers.IStore<T>.TryLoad(T& item) at Microsoft.Bot.Builder.Internals.Fibers.ErrorResilientStore1.Microsoft.Bot.Builder.Internals.Fibers.IStore.TryLoad(T& item)

Thanks!

from botbuilder.standard.

CXuesong avatar CXuesong commented on September 21, 2024

Yes, the source of problem is StoreInstanceByFieldsSurrogate registered in ReflectionSurrogateModule , which is used to make non-serializable types "serializable" by persisting and restoring their fields.

The problem is, In .NET Core, RuntimeType is not serializable, and BinaryFormatter will try to use it to deserialize it. But as I have mentioned in dotnet/corefx#23785, BinaryFormatter in .NET Core does not support resolving this Type instace of RuntimeType very well, so I used my TypeSerializationSurrogate implementation to handle this.

When serializing your objects, TypeSerializationSurrogate almost has the lowest negative priority, while StoreInstanceByFieldsSurrogate has the priority of 2, so it will take precedence to my TypeSerializationSurrogate.

builder
.Register(c => new Serialization.StoreInstanceByFieldsSurrogate(priority: 2))
.Keyed<Serialization.ISurrogateProvider>(FiberModule.Key_SurrogateProvider)
.SingleInstance();

Thus, my suggestion is that you not take any shortcuts, but make your classes serializable, so that the use of StoreInstanceByFieldsSurrogate can be removed. If, still, you want to use this class, then copy the code above, and reduce the priority to a number greater than 10 - int.MaxValue.

from botbuilder.standard.

mastermaq avatar mastermaq commented on September 21, 2024

Thank you!

from botbuilder.standard.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.