.NETGURU
System.Runtime.Serialization Problem with UserControl
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngreuse' list.


Kevin Conroy
-- Moved from [aspngwebcontrols] to [aspngreuse] by Alex Lowe <Click here to reveal e-mail address> --

Hi everyone! I'm having one heck of a problem with a user control that I'm
writing. I've got a bunch of custom WebControls that I've written and that
I'm loading dynamically. They are put into a place holder in a static
WebUserControl. When I run my program everything is fine until the controls
begin to unload. Then I get this odd message:

*********************
"An unhandled exception of type
'System.Runtime.Serialization.SerializationException' occurred in Unknown
Module.

Additional information: The type System.Web.HttpException in Assembly
System.Web, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a is not marked as serializable."
*********************

I only see this message in a pop-up window through the VS.NET IDE when I'm
running my project. When I run a complied version outside of the IDE I am
presented with no error message.

After stepping through the disassembly of the unload methods in the
framework, I've found that this message is being generated in
System.Web.UI.Control::OnUnload. I think that the problem MAY be that I'm
not non-LiteralControls in my form. (See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemWebUIHtmlControlsHtmlContainerControlClassInnerHtmlTopic.asp)
When I look at the Form1 object, the InnerHtml and the InnerText are:
"<error: an exception of type: {System.Web.HttpException} occurred>" Form1's
controls are two LiteralControls and one ASP:ListCriteria control (my custom
control) so that explains why InnerHtml has an HttpException. However, why
am I only seeing this exception when the framework attempts to serialize it
during the Unload phase?

I've made Form1 <NonSerializable()> in my code-behind file thinking that it
might prevent the Serialization call on the HttpException, but it didn't
work.

This exception isn't fatal so it's not a big deal, but it's getting very
annoying to have to hit "Continue" whenever I'm running it through the IDE.
Any suggestions on how to fix this? Thanks.

-- Kevin

Here's part of my code:
Lists_Main.aspx
****************
<%@ Register TagPrefix="cc1" Namespace="QueryProUI" Assembly="QueryProUI"
%>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Lists_Main.aspx.vb"
Inherits="QueryProWeb.Pages.Lists.Lists_Main" enableviewstate="false"
EnableSessionState="False" %>
<%@ Register TagPrefix="querypro" TagName="ListCriteria"
Src="../Controls/ListCriteria.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table>
<tr>
<td>
<querypro:ListCriteria id="ListCriteria1" runat="server" />
</td>
</tr>
</table>
</form>
</body>
</HTML>
****************

ListCriteria.ascx
****************
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="ListCriteria.ascx.vb"
Inherits="QueryProWeb.Controls.ListCriteria"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"; %>
<table border="0" cellpadding="0" cellspacing="0" style="BORDER-COLLAPSE:
collapse" bordercolor="#111111" id="ListCriteria">
<tr>
<td class="Box_Header" nowrap align="left" valign="top"><img border="0"
src="../images/HeaderIcon.gif" align="absMiddle" width="17"
height="23"> 
Criteria for Current List</td>
<td class="Box_Header" align="right" valign="top"><input type="button"
value="Customize Criteria" name="B1" class="button"><img border="0"
src="../images/HeaderIcon_R.gif" width="8" height="23"></td>
</tr>
<asp:PlaceHolder id="Criteria" runat="server">Dynamically created controls
go here!</asp:PlaceHolder>
<tr>
<td colspan="2">
<table cellpadding="6" class="Box_Inner" border="0"
bordercolor="#800080" width="100%" cellspacing="0">
<tr>
<td valign="top"><asp:button id="Button1" runat="server"
CommandArgument="WebForm1.aspx" CommandName="Post" Text="Calculate
Count"></asp:button></td>
</tr>
</table>
</td>
</tr>
</table>
****************

Reply to this message...
 
    
Daniel Naumann
Kevin,

I'm probably way off with this line of thought, but I've just read a book on
building custom controls so I've got them on the brain. Maybe the page is
implicitly trying to add your custom controls state to the page's view state.
Unless your custom controls implement the ISerializable interface (or something
like that), then they won't serialize.

Just a guess, sorry I can't provide to much help......

Daniel.

-----Original Message-----
From: Kevin Conroy [mailto:Click here to reveal e-mail address]
Sent: 26-Jul-2002 12:17
To: aspngreuse
Subject: [aspngreuse] System.Runtime.Serialization Problem with
UserControl

-- Moved from [aspngwebcontrols] to [aspngreuse] by Alex Lowe
<Click here to reveal e-mail address> --

Hi everyone! I'm having one heck of a problem with a user control that I'm
writing. I've got a bunch of custom WebControls that I've written and that
I'm loading dynamically. They are put into a place holder in a static
WebUserControl. When I run my program everything is fine until the controls
begin to unload. Then I get this odd message:

*********************
"An unhandled exception of type
'System.Runtime.Serialization.SerializationException' occurred in Unknown
Module.

Additional information: The type System.Web.HttpException in Assembly
System.Web, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a is not marked as serializable."
*********************

I only see this message in a pop-up window through the VS.NET IDE when I'm
running my project. When I run a complied version outside of the IDE I am
presented with no error message.

After stepping through the disassembly of the unload methods in the
framework, I've found that this message is being generated in
System.Web.UI.Control::OnUnload. I think that the problem MAY be that I'm
not non-LiteralControls in my form. (See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemWebUIHtmlControlsHtmlContainerControlClassInnerHtmlTopic.asp)
When I look at the Form1 object, the InnerHtml and the InnerText are:
"<error: an exception of type: {System.Web.HttpException} occurred>" Form1's
controls are two LiteralControls and one ASP:ListCriteria control (my custom
control) so that explains why InnerHtml has an HttpException. However, why
am I only seeing this exception when the framework attempts to serialize it
during the Unload phase?

I've made Form1 <NonSerializable()> in my code-behind file thinking that it
might prevent the Serialization call on the HttpException, but it didn't
work.

This exception isn't fatal so it's not a big deal, but it's getting very
annoying to have to hit "Continue" whenever I'm running it through the IDE.
Any suggestions on how to fix this? Thanks.

-- Kevin

Here's part of my code:
Lists_Main.aspx
****************
<%@ Register TagPrefix="cc1" Namespace="QueryProUI" Assembly="QueryProUI"
%>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Lists_Main.aspx.vb"
Inherits="QueryProWeb.Pages.Lists.Lists_Main" enableviewstate="false"
EnableSessionState="False" %>
<%@ Register TagPrefix="querypro" TagName="ListCriteria"
Src="../Controls/ListCriteria.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table>
<tr>
<td>
<querypro:ListCriteria id="ListCriteria1" runat="server" />
</td>
</tr>
</table>
</form>
</body>
</HTML>
****************

ListCriteria.ascx
****************
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="ListCriteria.ascx.vb"
Inherits="QueryProWeb.Controls.ListCriteria"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"; %>
<table border="0" cellpadding="0" cellspacing="0" style="BORDER-COLLAPSE:
collapse" bordercolor="#111111" id="ListCriteria">
<tr>
<td class="Box_Header" nowrap align="left" valign="top"><img border="0"
src="../images/HeaderIcon.gif" align="absMiddle" width="17"
height="23"> 
Criteria for Current List</td>
<td class="Box_Header" align="right" valign="top"><input type="button"
value="Customize Criteria" name="B1" class="button"><img border="0"
src="../images/HeaderIcon_R.gif" width="8" height="23"></td>
</tr>
<asp:PlaceHolder id="Criteria" runat="server">Dynamically created controls
go here!</asp:PlaceHolder>
<tr>
<td colspan="2">
<table cellpadding="6" class="Box_Inner" border="0"
bordercolor="#800080" width="100%" cellspacing="0">
<tr>
<td valign="top"><asp:button id="Button1" runat="server"
CommandArgument="WebForm1.aspx" CommandName="Post" Text="Calculate
Count"></asp:button></td>
</tr>
</table>
</td>
</tr>
</table>
****************
| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
Kevin Conroy
Thanks for the suggestion.

As is usually the case when I post a message for help, I figured out what
the problem was shortly after I sent the message. Stupid Murphy's Law.

What was happening was I was spawning another thread to process and log
messages in a message queue at the Page.OnUnload event. Thanks to the
wonders of the .NET framework, I've been able to make the log method
asynchronous and have optimized it for processing messages in batch, the
combination of which has shaved 2 to 3 seconds off of page execution time
from our old ASP classic system. When I moved the processing of the log
queue to a separate thread, it was attempting to write to the output stream
after the stream had been closed and the rendered Html sent to the client,
generating an HttpException. Seems kind of odd that I'd get a module unknown
error since the IDE knows about all of the threads I'm running and
theoretically should have told me that I was attempting to write to a closed
output stream rather than saying that there was a Serialization error. Very
odd.

Just thought I'd explain what the issue was in case anyone else ever tries
to write to a closed Html output stream.

-- Kevin

----- Original Message -----
From: "Daniel Naumann" <Click here to reveal e-mail address>
To: "aspngreuse" <Click here to reveal e-mail address>
Sent: Thursday, July 25, 2002 6:08 PM
Subject: [aspngreuse] RE: System.Runtime.Serialization Problem with
UserControl

[Original message clipped]

Reply to this message...
 
 
System.Runtime.Serialization.ISerializable
System.Runtime.Serialization.SerializationException
System.Web.HttpException
System.Web.UI.Control
System.Web.UI.Page
System.Web.UI.UserControl
System.Web.UI.WebControls.PlaceHolder
System.Windows.Forms.UserControl




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification