我知道這個錯誤是什麼,如何解決它,等我的對象是如何進入ASP.NET頁面狀態的?
我的問題是,我不知道爲什麼我的,我發展當前頁面時,我並沒有直接使用Foo類引發此錯誤任何方式,我也不會設置任何視圖狀態。我使用回發很多,但正如我所說,我不存儲視圖狀態等一個整數的任何東西。
我使用nhibernate,如果這是相關的。
任何想法,爲什麼我需要將這些類標記爲可序列化,不被使用?我應該從哪裏開始調查?
[SerializationException: Type 'FlexiCommerce.Persistence.NH.ContentPersister' in Assembly 'FlexiCommerce.Persistence.NH, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +9434541
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +247
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +160
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) +218
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +388
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +444
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +133
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph) +13
System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value) +2937
[ArgumentException: Error serializing value 'Music#2' of type 'FlexiCommerce.Components.Category.']
System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value) +3252
System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value) +2276
[ArgumentException: Error serializing value 'System.Object[]' of type 'System.Object[].']
System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value) +3252
System.Web.UI.ObjectStateFormatter.Serialize(Stream outputStream, Object stateGraph) +116
System.Web.UI.ObjectStateFormatter.Serialize(Object stateGraph) +57
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Serialize(Object state) +4
System.Web.UI.Util.SerializeWithAssert(IStateFormatter formatter, Object stateGraph) +37
System.Web.UI.HiddenFieldPageStatePersister.Save() +79
System.Web.UI.Page.SavePageStateToPersistenceMedium(Object state) +108
System.Web.UI.Page.SaveAllState() +315
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2492
禁用視圖狀態/會話,讓事情中斷,快速瞭解有狀態和無狀態之間的區別,擁有一個燈泡時刻,重新思考一切,重新構建它,瞧。抱歉不能抵制。但是就像J桑德斯說它進入你的頁面狀態不知何故 – 2010-03-23 20:04:44
是的,發佈代碼。 – Paco 2010-03-23 20:07:35
我知道我的一個對象正在被序列化。我沒有意識到有一個隱藏的領域包含了很多的依賴關係。使用[NonSerialized]解決了這個問題。 – 2010-03-24 14:07:33