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

Thread is closed for posting
3 posts, 1 answers
  1. Jafin
    Jafin avatar
    86 posts
    Member since:
    Nov 2005

    Posted 22 Jun 2009 Link to this post

    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. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 22 Jun 2009 Link to this post

    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.
  3. Jafin
    Jafin avatar
    86 posts
    Member since:
    Nov 2005

    Posted 22 Jun 2009 Link to this post

    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

Back to Top