views:

85

answers:

2

I know what this error is, how to fix it, etc.

My question is that I don't know why my current page I am developing is throwing this error when I am not using the foo class directly in any way, nor am I setting anything to the viewstate. I am using postbacks alot, but like I said, I am not storing anything in the viewstate etc one integer.

I am using nhibernate if that is relevant.

Any idea why I need to mark this classes as serializable that arent being used? Where should I start investigating?

[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
+1  A: 

Are you perhaps databinding objects of this kind? It's clearly gotten into page state somehow.

John Saunders
A: 

I would assume you have enabled some of the caching elements either for query caching, or enabled actual object graph caching of NHibernate (if so probably using the SysCacheProvider which is just HttpRuntime.Cache).

I would recommend regardless of caching usage or not to mark every Domain object as serializable as it's very reasonable at some point that it will either go over the wire or just into a ViewState/Session container.

Chris Marisic