gpt4 book ai didi

c# - 结构图 HttpSessionLifecycle 对象序列化

转载 作者:行者123 更新时间:2023-11-30 22:36:01 27 4
gpt4 key购买 nike

我正在使用 StructureMap存储 session 对象:

config.For<SessionContext>().LifecycleIs(new HttpSessionLifecycle());

一切正常,所以我可以使用 DI 轻松检索 session 对象.

但现在我需要将我的 session 从进程内切换到数据库,但我收到以下错误。

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode. ---> System.Runtime.Serialization.SerializationException: Type 'StructureMap.Pipeline.MainObjectCache' in Assembly 'StructureMap, Version=2.6.2.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223' is not marked as serializable.

我该如何解决这个问题?

最佳答案

问题出在 StructureMap 中。我已经将 [Serializable] 属性添加到 MainObjectCache 类和其他一些并对其进行了测试。现在可以了。可以在 this 中找到修复程序拉取请求。

希望@Joshua Flanagan 尽快将这些更改合并到 master 分支中,最终解决问题。

编辑:

Thanks, I've pulled in your change (and a few others) and pushed a 2.6.3 release. Edit your answer to say it was a bug fixed in 2.6.3 and mark it as the accepted answer. – Joshua Flanagan

关于c# - 结构图 HttpSessionLifecycle 对象序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7192645/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com