Просмотр объектов в сеансе запущенного приложения ASP.NET - PullRequest
2 голосов
/ 24 июля 2011

Я пытаюсь перевести мое приложение в состояние сеанса вне процесса и не могу найти, какой объект сеанса не сериализуется - трассировка стека YSOD не обнаруживается.

Можно ли просмотретьобъекты или, по крайней мере, типы объектов, хранящихся в данный момент в состоянии сеанса работающего приложения?Если не считать присоединения отладчика к работающему приложению и наличия его исходного кода, я не знаю, возможно ли это.

Я использую Alachisoft NCache, поэтому вот их трассировка стека, хотя это не полезно:

System.Web.HttpException (0x80004005): 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 'System.Web.UI.Control' in Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
   at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
   at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer)
   at System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer)
   at System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer)
   at System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter writer)
   at Alachisoft.NCache.Web.SessionState.SessionSerializationUtil.Serialize(SessionStateStoreData sessionData)
   at Alachisoft.NCache.Web.SessionState.NSessionStoreProvider.InsertContents(HttpContext context, SessionStateStoreData data, SessionStateActions flag, Int32 timeout)
   at Alachisoft.NCache.Web.SessionState.NSessionStoreProvider.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData items, Object lockID, Boolean newItem

ОБНОВЛЕНИЕ

У меня тожерезультаты с использованием состояния сеанса SQL Server:

[SerializationException: Type 'System.Web.UI.Control' in Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.]
   System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +12475327
   System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +361
   System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +413
   System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) +556
   System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +969
   System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +1016
   System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +319
   System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1559

[HttpException (0x80004005): 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.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +2273923
   System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer) +49
   System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter writer) +811
   System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream) +342
   System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length, Boolean compressionEnabled) +99
   System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +3673544
   System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +929
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270

1 Ответ

0 голосов
/ 25 июля 2011

На самом деле ваше исключение говорит вам точно, что это такое: у вас есть UserControl, который где-то помещен в сессию, и он не помечен как сериализуемый.

---> System.Runtime.Serialization.SerializationException: Тип 'System.Web.UI.Control' в сборке 'System.Web, версия = 4.0.0.0, культура = нейтральная, PublicKeyToken = b03f5f7f11d50a3a 'не помечен как сериализуемый.

Обновление

Вы можете поместить некоторый код на странице OnLoad (или аналогичный), который просто повторяет сеанс и выводит его, это не так уж сложно:

foreach(var key in Session.Keys)
   Response.Write(String.Format("{0}: {1}<br/>", key, Session[key]);

Это не идентифицирует точный код / ​​страницу, но должно дать вам некоторые критерии поиска.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...