Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error serializing for view state

I am having problems serialising data for the view state. I am using VS2010 and when trying to add a property to the view state I get the following error message:

Error serializing value 'System.Collections.Generic.List`1[Access.ARW.Business.Filters.Parameters.Parameter]' of type 'System.Collections.Generic.List`1[[Access.ARW.Business.Filters.Parameters.Parameter, Access.ARW.Business, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].'

I have added a [Serializable] attribute above the classes I am trying to serialise but I still get this error...any ideas

Here is the property declaration which is in Class A:

private List<Filters.Parameters.Parameter> ReportParameters
{
   get
   {
       if (ViewState["ReportParameters"] == null)
       {
           ViewState["ReportParameters"] =
               new List<Filters.Parameters.Parameter>();
       }
       return (List<Filters.Parameters.Parameter>) ViewState["ReportParameters"];
   }

   set
   {
       ViewState["ReportParameters"] = value;
   }
}
like image 848
user559142 Avatar asked Feb 02 '12 16:02

user559142


1 Answers

Did you miss adding the Serializable attribute to one of the components of the class? Try adding the parts of the class one-by-one to ViewState until you find the one that is wrong.

like image 114
Steve Wellens Avatar answered Nov 07 '22 12:11

Steve Wellens