user559142
user559142

Reputation: 12517

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;
   }
}

Upvotes: 5

Views: 8235

Answers (1)

Steve Wellens
Steve Wellens

Reputation: 20640

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.

Upvotes: 7

Related Questions