Error serializing - Exception of type System.Web.HttpUnhandledException was thrown.

Solved:

You have to add [Serializable] attribute in the class and also add inherited class if you extend on that class.

Why?
Because you have created List or Dictionary type of property


Inner Exception:
System.ArgumentException: Error serializing value 'ModelClass' of type 'ModelClass.' ---> System.Runtime.Serialization.SerializationException: Type 'IMR.Model.Models.Admin.UserInOutLogSearch' in Assembly 'IMR.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 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.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   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.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
   at System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value)
   --- End of inner exception stack trace ---
   at System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value)
   at System.Web.UI.ObjectStateFormatter.Serialize(Stream outputStream, Object stateGraph)
   at System.Web.UI.ObjectStateFormatter.Serialize(Object stateGraph, Purpose purpose)
   at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Serialize(Object state, Purpose purpose)
   at System.Web.UI.Util.SerializeWithAssert(IStateFormatter2 formatter, Object stateGraph, Purpose purpose)
   at System.Web.UI.HiddenFieldPageStatePersister.Save()
   at System.Web.UI.Page.SavePageStateToPersistenceMedium(Object state)
   at System.Web.UI.Page.SaveAllState()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Comments

Popular posts from this blog

Add Image through base64 on PDF in itextsharp

Set span value using jquery and javascript

how to insert text and tags at the cursor CKEDITOR