Crash in GridSettingsPersister class

6 posts, 0 answers
  1. Steve Barak
    Steve Barak avatar
    5 posts
    Member since:
    Aug 2008

    Posted 11 Mar 2011 Link to this post


    I our project we are using  Class GridSettingsPersister in the link(   Previously when we  are Telerik.Web.UI version 2009.2.701.20  it was working fine.  We  upgrade Telerik.Web.UI version ()it is crashing in some page at Dim gridSettings() As Object = CType(formatter.Deserialize(reader), Object()).





    When we connected development database it is crashing.while it is test in testing database there was no issue.




    Its value of parameter ‘setting’ passed to LoadSettings() function




    Development Database :






    Testing Database







    We try this solution  Set the MaxPageStateFieldLength proprety of Pages in Web.config file

    but still issue existing .

    The error message while debugging is  'The serialized data is invalid'   but  browser show another runtime error message. Please  check the screen shot.


  2. Steve Barak
    Steve Barak avatar
    5 posts
    Member since:
    Aug 2008

    Posted 14 Mar 2011 Link to this post

    I think you posted comment on wrong post.

    Hi Terric Team,

    Could you please help us on this issue ?

  3. Veli
    Veli avatar
    2002 posts

    Posted 14 Mar 2011 Link to this post

    Hi Steve,

    The current implementation of the GridSettingsPersister does not support deserializing data that is serialized from a previous version of the assembly in which the GridSettingsPersister is defined. The problem is in the binary serialization, in particular. In the RadGrid Persisting Grid Settings on a Per-User Basis demo, you can note the GridSettingsCollection class implemented in the GridSettingsPersister.cs source code file. Objects of that class are the data that is actually getting serialized and deserialized. The LosFormatter that is used to serialize and deserialize this object uses binary serialization internally. Under default settings, binary serialization uses the full assembly name when identifying the full name of the class to which the serialized/deserialized object belongs. When you rebuild your project (or the assembly in which the GridSettingsCollection class is defined), the full name of the class (that includes also the assembly version) may change. At this point binary serialization will fail, expecting to find an assembly matching the same name and version as the assembly which the original object was serialized from.

    This issue is a limitation (or requirement) of binary serialization in particular. It is not directly related to the GridSettingsPersister, which is centered around extracting persisted settings from a RadGrid instance. The GridSettingsPersister behavior won't change if you implement another means of serializing and deserializing your saved grid settings (an object of type GridSettingsCollection). In this respect, serialization is detached from the persister behavior. It is easily customizable by providing your own implementation for the methods of the GridSettingsCollection class and you can implement your own serialization mechanism based on your needs (if binary serialization may not be suitable for your case).

    In fact, binary serialization can work for you, if you choose to use the BinaryFormatter (instead of the LosFormatter provided by default) and set the AssemblyFormat property to Simple. With this setting, assembly names of serialized and deserialized objects are not required to match exactly and you will not get the exception you are getting. The only requirement for this option is for your application to run in full trust. Medium trust environments do not allow binary serialization with simple assembly resolution and you cannot use this approach in shared hosting environments.

    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  4. Hunter
    Hunter avatar
    44 posts
    Member since:
    Aug 2012

    Posted 04 Oct 2012 Link to this post

    I know this is an older thread but I wanted to say thank you to Veli for the great information (saved me a bunch of time this morning).
  5. Grant
    Grant avatar
    12 posts
    Member since:
    Aug 2011

    Posted 07 Jul 2016 Link to this post



    I have a similar issue where I have a project that was serialising settings for a RadGrid and saving them in a SQL database as a string.


    I have since moved my project from a 'Web Site' to a 'Web Application' and also upgraded to use VB 14.


    Now when I run the project the LosFormatter.Deserialize(settings_string) fails with the error "The serialized data is invalid".


    I cannot change how the settings were formatted because they are all saved in the DB now and there are hundreds of entries.

    Is there any way you can suggest to deserialize and use these old strings from the DB in the new WebApp project ?


  6. Daniel
    Daniel avatar
    4949 posts

    Posted 12 Jul 2016 Link to this post

    Hello Grant,

    I'm not sure if there is a way to fix the saved state. You can try to deserialize the settings using the 'web site' you mentioned. Then you can re-save them with our persistence framework using the default XML serializer.

    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top