哪个对象不能序列化?状态服务器的 IIS 会话状态
Which object can't be serialized? IIS Session State with State Server
我是 运行 一个 IIS 下的 ASP.net 网站,带有状态服务器。一个对象无法序列化,但我不知道是哪个对象。 IIS 或 Visual Studio 有没有办法告诉我哪个对象序列化失败?
谢谢。
********** 12/3/2015 9:22:23 PM **********
Exception giud: 3fa14c14-cad5-48fa-a23a-7eccc3340093
Inner Exception Type: System.Web.HttpException
Inner Exception: 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.
Inner Source: System.Web
Inner Stack Trace:
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 System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream)
at System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length, Boolean compressionEnabled)
at System.Web.SessionState.OutOfProcSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem)
at System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Exception Type: System.Web.HttpException
Exception: Server Error: 500
Source: HttpError
Stack Trace:
您的情况抛出的异常类型为System.Web.HttpException
InnerException
的类型是 HttpException
检查内部异常的内部异常。它将根据 Reference Source of AltSerialization.WriteValueToStream
包含实际的序列化异常
用于序列化非值和非知名类型的 try/catch 块的源代码如下。您可以看到使用更详细的序列化异常作为内部异常构建的 HttpException。它将为您提供不可序列化的实际类型:
try {
formatter.Serialize(writer.BaseStream, value);
} catch (Exception innerException) {
HttpException outerException = new HttpException(SR.GetString(SR.Cant_serialize_session_state), innerException);
outerException.SetFormatter(new UseLastUnhandledErrorFormatter(outerException));
throw outerException;
}
我是 运行 一个 IIS 下的 ASP.net 网站,带有状态服务器。一个对象无法序列化,但我不知道是哪个对象。 IIS 或 Visual Studio 有没有办法告诉我哪个对象序列化失败?
谢谢。
********** 12/3/2015 9:22:23 PM **********
Exception giud: 3fa14c14-cad5-48fa-a23a-7eccc3340093
Inner Exception Type: System.Web.HttpException
Inner Exception: 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.
Inner Source: System.Web
Inner Stack Trace:
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 System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream)
at System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length, Boolean compressionEnabled)
at System.Web.SessionState.OutOfProcSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem)
at System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Exception Type: System.Web.HttpException
Exception: Server Error: 500
Source: HttpError
Stack Trace:
您的情况抛出的异常类型为System.Web.HttpException
InnerException
的类型是 HttpException
检查内部异常的内部异常。它将根据 Reference Source of AltSerialization.WriteValueToStream
包含实际的序列化异常用于序列化非值和非知名类型的 try/catch 块的源代码如下。您可以看到使用更详细的序列化异常作为内部异常构建的 HttpException。它将为您提供不可序列化的实际类型:
try {
formatter.Serialize(writer.BaseStream, value);
} catch (Exception innerException) {
HttpException outerException = new HttpException(SR.GetString(SR.Cant_serialize_session_state), innerException);
outerException.SetFormatter(new UseLastUnhandledErrorFormatter(outerException));
throw outerException;
}