This is a migrated thread and some comments may be shown as answers.

Telerik.Charting.Styles.Unit not marked Serializable - Viewstate problem

2 Answers 87 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Jafin
Top achievements
Rank 2
Jafin asked on 22 Jun 2009, 05:09 AM
Attempting an in-place upgrade from Q3-2008 to Q2 2009 beta.
On a page with multiple controls I get the following error when the page goes to save viewstate.

Type 'Telerik.Charting.Styles.Unit' in Assembly 'Telerik.Web.UI, Version=2009.2.616.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4' is not marked as serializable.

Checking with Reflector, indeed the Serializable attribute is gone from 2009.2  but exists in 2008.3 .  Would there be something I am doing wrong causing this error?

Page works fine in Q3-2008.

Thanks,
Jason




2 Answers, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 22 Jun 2009, 04:15 PM
Hi Jafin,

Indeed the functionality has been altered a bit in the latest version due to some problems with the SerializableAttribute in our Reporting product (ASP.NET and Reporting share common charting engine). We will do our best to resolve these issues for the Q2 2009 official release but for the time being you can use the following equivalent approach to serialize the viewstate in SessionStatePersister + session state stored in SQL Server (this is the most common cause that triggers the serialization exception):

Page code-behind:

protected override void SavePageStateToPersistenceMedium(object viewState) 
    if (viewState == null)  
        return
 
    LosFormatter formatter = new LosFormatter(); 
    StringWriter writer = new StringWriter(); 
    try 
    { 
        formatter.Serialize(writer, viewState); 
        Session["ViewState"] = writer.ToString(); 
    } 
    catch 
    { 
        throw new HttpException("Invalid view state"); 
    } 
    finally 
    { 
        writer.Close(); 
    } 
 
protected override object LoadPageStateFromPersistenceMedium() 
    object viewStateObj = null
 
    LosFormatter formatter = new LosFormatter(); 
    object sessionViewState = Session["ViewState"]; 
    try 
    { 
        viewStateObj = formatter.Deserialize(sessionViewState.ToString()); 
    } 
    catch 
    { 
        throw new HttpException("Invalid view state"); 
    } 
 
    return viewStateObj; 


Kind regards,
Manuel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jafin
Top achievements
Rank 2
answered on 22 Jun 2009, 11:24 PM
Thank you, indeed I was serializing viewstate to a sharedcache provider, which was using a BinarySerializer.  Changing to the LosFormatter appears to of resolved the problem.

Thanks.
Jason

Tags
Chart (Obsolete)
Asked by
Jafin
Top achievements
Rank 2
Answers by
Giuseppe
Telerik team
Jafin
Top achievements
Rank 2
Share this question
or