在会话视图对象正在运行的ASP.NET应用程序 [英] View Objects in Session of a Running ASP.NET Application
问题描述
我想我的应用程序转移到外的进程内会话状态,无法找到其会话对象未能序列化 - 在YSOD堆栈跟踪是unrevealing
是否可以查看对象,或至少对象的类型,当前存储在运行的应用程序的会话状态?短调试器附加到正在运行的应用程序,其源$ C $ C可用的,我不知道这是可能的。
我使用Alachisoft的nCache,所以这里是他们的堆栈跟踪,但它不是有用的:
System.Web.HttpException(0X80004005):无法序列化会话状态。在'的StateServer'和'的SQLServer模式,ASP.NET将序列化会话状态的对象,并因此不可序列化对象或对象MarshalByRef不允许。如果类似的序列化是通过在自定义模式自定义会话状态存储做了同样的限制也适用。 ---> System.Runtime.Serialization.SerializationException:键入System.Web.UI.Control在大会'System.Web程序,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a'未标记为可序列。
在System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType型)
在System.Runtime.Serialization.FormatterServices.GetSerializableMembers(类型类型,的StreamingContext上下文)
在System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
在System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(obj对象,ISurrogateSelector surrogateSelector,的StreamingContext上下文,SerObjectInfoInit serObjectInfoInit,IFormatterConverter来换算,ObjectWriter objectWriter,SerializationBinder粘合剂)
在System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo,NameInfo memberNameInfo,NameInfo typeNameInfo)
在System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(对象图,标题[] inHeaders,__BinaryWriter serWriter,布尔FCHECK)
在System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(流serializationStream,对象图,标题[]头,布尔FCHECK)
在System.Web.Util.AltSerialization.WriteValueToStream(对象价值的BinaryWriter作家)
在System.Web.Util.AltSerialization.WriteValueToStream(对象价值的BinaryWriter作家)
在System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(对象价值的BinaryWriter作家)
在System.Web.SessionState.SessionStateItemCollection.Serialize(的BinaryWriter作家)
在Alachisoft.NCache.Web.SessionState.SessionSerializationUtil.Serialize(SessionStateStoreData sessionData)
在Alachisoft.NCache.Web.SessionState.NSessionStoreProvider.InsertContents(HttpContext的背景下,SessionStateStoreData数据,SessionStateActions标志的Int32超时)
在Alachisoft.NCache.Web.SessionState.NSessionStoreProvider.SetAndReleaseItemExclusive(HttpContext的背景下,串ID,SessionStateStoreData项目,对象lockID,布尔的newitem
更新
我必须使用SQL Server会话状态相同的结果:
[SerializationException:键入System.Web.UI.Control在大会'System.Web程序,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a'未标记为序列化的。]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType型)12475327
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(类型类型,的StreamingContext上下文)361
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()413
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(obj对象,ISurrogateSelector surrogateSelector,的StreamingContext上下文,SerObjectInfoInit serObjectInfoInit,IFormatterConverter来换算,ObjectWriter objectWriter,SerializationBinder粘合剂)556
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo,NameInfo memberNameInfo,NameInfo typeNameInfo)969
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(对象图,标题[] inHeaders,__BinaryWriter serWriter,布尔FCHECK)1016
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(流serializationStream,对象图,标题[]头,布尔FCHECK)+319
System.Web.Util.AltSerialization.WriteValueToStream(对象的价值,作家的BinaryWriter)1559[HttpException(0x80004005的):无法序列化会话状态。在'的StateServer'和'的SQLServer模式,ASP.NET将序列化会话状态的对象,并因此不可序列化对象或对象MarshalByRef不允许。如果类似的序列化是通过在自定义模式自定义会话状态存储做了同样的限制也适用。]
System.Web.Util.AltSerialization.WriteValueToStream(对象的价值,作家的BinaryWriter)2273923
System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(对象的价值,作家的BinaryWriter)+49
System.Web.SessionState.SessionStateItemCollection.Serialize(的BinaryWriter作家)811
System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData项目,涧流)342
System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData项目的Int32 initialStreamSize,字节[]放大器; BUF,的Int32&安培;长度,布尔COM pressionEnabled)+99
System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext的背景下,串ID,SessionStateStoreData项目,对象lockId,布尔的newitem)3673544
System.Web.SessionState.SessionStateModule.OnReleaseState(对象源,EventArgs的EventArgs的)929
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+ 80
System.Web.HttpApplication.ExecuteStep(IExecutionStep一步,布尔和放大器; completedSynchronously)+270
其实你的异常告诉你它到底是什么:你有一个正在被放入用户控件
会议的地方,它是没有标记为可序列。
---> System.Runtime.Serialization.SerializationException:键入System.Web.UI.Control在大会'System.Web程序,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a'未标记为可序列化。
更新
您可以把一些code在页面的OnLoad(或类似),简单地遍历了会议,并转储说出来,这不是太困难的:
的foreach(在Session.Keys VAR键)
回复于(的String.Format({0}:{1}< BR />中,钥匙,会话[关键]);
这不是要找出确切的code /页,但它应该给你一些搜索条件。
I am trying to move my app to out-of-proc session state and can't find which session object is failing to serialize - the YSOD stack trace is unrevealing.
Is it possible to view the objects, or at least the types of objects, currently stored in session state of a running application? Short of attaching a debugger to a running app, and having its source code available, I don't know if this is possible.
I'm using Alachisoft NCache, so here's their stack trace, though it's not helpful:
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
UPDATE
I have the same results using SQL Server session state:
[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
Actually your exception tells you exactly what it is: You have a UserControl
that is being placed into the Session somewhere and it is not marked as serializable.
---> 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.
Update
You can put some code in a page OnLoad (or similar) that simply iterates the session and dumps that out, it's not too difficult:
foreach(var key in Session.Keys)
Response.Write(String.Format("{0}: {1}<br/>", key, Session[key]);
That's not going to identify the exact code/page but it should give you some search criteria.
这篇关于在会话视图对象正在运行的ASP.NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!