Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Error on postback after adding ViewState

Posted on 2008-10-16
5
4,303 Views
Last Modified: 2013-12-17
After adding the line ViewState["CachedControls"] = data to my property, I now receive this error on a postback:

"A Runtime Error has occurred.
Do you wish to Debug?
Line: 4723
Error: Sys.WebForms.PageRequestManagerServerErrorException: Error serializing value 'System.Collections.Generic.List`1[System.Collections.IEnumerable]' of type 'System.Collections.Generic.List`1[[System.Collections.IEnumerable, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].'"

I have Script Manager and UpdatePanel controls on the page, and it breaks into generated JavaScript code within an onReadyStateChange event.  The call stack is extremely unhelpful in this matter.
private List<IEnumerable> ControlData
{
	get 
	{
		List<IEnumerable> data =(List<IEnumerable>)ViewState["CachedControls"];
		if (data == null)
		{
			EditController editControl = new EditController(SearchType); 
			data = editControl.GetData();
			ViewState["CachedControls"] = data;
		}
 
		return data; 
	}
}

Open in new window

0
Comment
Question by:PerlChaser
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:JunkMan
ID: 22736016
what exactly is .getData() returning, one of the IEnumerable's returned is not marked a Serializable

like so:
[Serializable]
public class foo:IEnumerable{
 
}

Open in new window

0
 
LVL 1

Author Comment

by:PerlChaser
ID: 22736136
I will get back to you on this tomorrow, I need to head home.

PerlChaser
0
 
LVL 1

Author Comment

by:PerlChaser
ID: 22739964
GetData returns an IEnumerable list containing:
1. Dictionary<string, string>
2. IEnumerable<Term>
Term is marked Serializable.
0
 
LVL 3

Accepted Solution

by:
JunkMan earned 125 total points
ID: 22741563
I vaguely remember having issues when serializing dictonaries. Could you trim the getData method to return either one or the other type? that way you will know exactly which one is causing you the problem.

Also double check if Term is not referring to any object that might not be serializable.
0
 
LVL 1

Author Comment

by:PerlChaser
ID: 22742657
Yes, serializing this object was the problem.  I chose to store just the Dictionary in the ViewState since that was the only piece I needed between calls.  Thank you very much for your help, JunkMan.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question