Solved

Error on postback after adding ViewState

Posted on 2008-10-16
5
4,207 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
Comment Utility
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
Comment Utility
I will get back to you on this tomorrow, I need to head home.

PerlChaser
0
 
LVL 1

Author Comment

by:PerlChaser
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now