2

アプリをプロセス外のセッション状態に移行しようとしていますが、シリアル化に失敗しているセッションオブジェクトが見つかりません-YSODスタックトレースが明らかになりません。

実行中のアプリケーションのセッション状態で現在保存されているオブジェクト、または少なくともオブジェクトのタイプを表示することは可能ですか?実行中のアプリにデバッガーを接続し、そのソースコードを利用できるようにすることを除けば、これが可能かどうかはわかりません。

私はAlachisoftNCacheを使用しているので、これがスタックトレースですが、役に立ちません。

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

アップデート

SQLServerのセッション状態を使用しても同じ結果が得られます。

[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
4

1 に答える 1

0

実際、例外はそれが何であるかを正確に示しています。UserControlセッションのどこかに配置されており、シリアライズ可能としてマークされていません。

---> System.Runtime.Serialization.SerializationException:アセンブリ 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' の'System.Web.UI.Control'と入力します。

アップデート

セッションを反復してダンプするだけのコードをページ OnLoad (または同様のもの) に入れることができますが、それほど難しくありません。

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

正確なコード/ページを特定することはできませんが、いくつかの検索基準が得られるはずです。

于 2011-07-24T20:00:41.207 に答える