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

Crash in GridSettingsPersister class

5 Answers 58 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steve Barak
Top achievements
Rank 1
Steve Barak asked on 11 Mar 2011, 04:08 PM

Hi

I our project we are using  Class GridSettingsPersister in the link(http://www.telerik.com/help/aspnet/grid/grdsavingsettingsonperuserbasis.html).   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 :

 

/wEUKwAFFgQeAl9jAgEeATAWBB4DX2ZuBRFXb3JrZmxvd0RhdGVfdGVtcB4DX3NvCyl1VGVsZXJpay5XZWIuVUkuR3JpZFNvcnRPcmRlciwgVGVsZXJpay5XZWIuVUksIFZlcnNpb249MjAwOS4yLjcwMS4yMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj0xMjFmYWU3ODE2NWJhM2Q0AhQrAAAUKhJTeXN0ZW0uV2ViLlVJLlBhaXIIDwIDHA8CBBwPAgUbAAAAAAAAKEAHAAAADwIGGwAAAAAAAERABwAAAA8CBxsAAAAAAAA2QAcAAAAPAggbAAAAAAAAGEAHAAAADwIJGwAAAAAAACRABwAAAA8CChsAAAAAAAAkQAcAAAAWCGhoZ2dnZ2doAgo=

 

 

 

Testing Database

 

 

 

/wEUKwAFFgQeAl9jAgEeATAWAh4DX2ZuBRFXb3JrZmxvd0RhdGVfdGVtcBQrAAAUKhJTeXN0ZW0uV2ViLlVJLlBhaXIIDwIDHA8CBBwPAgUbAAAAAAAAKEAHAAAADwIGGwAAAAAAAERABwAAAA8CBxsAAAAAAAA2QAcAAAAPAggbAAAAAAAAGEAHAAAADwIJGwAAAAAAACRABwAAAA8CChsAAAAAAAAkQAcAAAAWCGhoZ2dnZ2doAhQ=

 

 

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.

 

5 Answers, 1 is accepted

Sort by
0
Steve Barak
Top achievements
Rank 1
answered on 14 Mar 2011, 07:19 AM
patty,
I think you posted comment on wrong post.

Hi Terric Team,

Could you please help us on this issue ?

Raj
0
Veli
Telerik team
answered on 14 Mar 2011, 04:31 PM
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.

Veli
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!
0
Hunter
Top achievements
Rank 1
answered on 04 Oct 2012, 04:27 PM
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).
0
Grant
Top achievements
Rank 1
answered on 07 Jul 2016, 06:35 PM

Hi,

 

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 ?

Thanks.

0
Daniel
Telerik team
answered on 12 Jul 2016, 10:43 AM
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.

Regards,
Daniel
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.
Tags
General Discussions
Asked by
Steve Barak
Top achievements
Rank 1
Answers by
Steve Barak
Top achievements
Rank 1
Veli
Telerik team
Hunter
Top achievements
Rank 1
Grant
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or