<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Keebler/Blog &#187; C#</title>
	<atom:link href="http://www.keebler.net/blog/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.keebler.net/blog</link>
	<description></description>
	<lastBuildDate>Sat, 21 Nov 2009 06:07:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ASPX: Don&#8217;t put UserControls inside of code blocks</title>
		<link>http://www.keebler.net/blog/2008/11/30/aspx-dont-put-usercontrols-inside-of-code-blocks/</link>
		<comments>http://www.keebler.net/blog/2008/11/30/aspx-dont-put-usercontrols-inside-of-code-blocks/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 01:18:22 +0000</pubDate>
		<dc:creator>Jonathan</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.keebler.net/blog/?p=3808</guid>
		<description><![CDATA[
I was trying to figure out why an ASPX page was taking so long to render.  I put time markers all through my code, but the slowdown was happening between the end of the Page_Load execution, and the beginning of the page render.  There were no exceptions or anything.


Finally, by a painful process [...]


Related posts:<ol><li><a href='http://www.keebler.net/blog/2009/01/03/net-monitoring-windows-processes-from-aspx-webpage/' rel='bookmark' title='Permanent Link: .NET: Monitoring Windows processes from ASPX webpage'>.NET: Monitoring Windows processes from ASPX webpage</a> <small> I was recently working on some ScribbleLive features that...</small></li><li><a href='http://www.keebler.net/blog/2005/07/12/cojax-source-code-viewer/' rel='bookmark' title='Permanent Link: Cojax Source Code Viewer'>Cojax Source Code Viewer</a> <small> Here&#8217;s a neat Ajax code viewer for the Community...</small></li><li><a href='http://www.keebler.net/blog/2006/01/07/bar-code-clock-in-javascript/' rel='bookmark' title='Permanent Link: Bar Code Clock in Javascript'>Bar Code Clock in Javascript</a> <small> I honestly have no idea why watching this clock...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>
I was trying to figure out why an ASPX page was taking so long to render.  I put time markers all through my code, but the slowdown was happening between the end of the Page_Load execution, and the beginning of the page render.  There were no exceptions or anything.
</p>
<p>
Finally, by a painful process of elimination, it turned out to be a block of code like this in the ASPX file.  At render, it was deciding whether to include a custom UserControl.  While the code executed properly, the only hint of a problem was iistrace showing &#8220;IISISAPI: ISAPI_END &#8211; IIS ends processing an ISAPI Request&#8221; taking a long time.
</p>
<pre class="syntax-highlight:c#">
&lt;% if( IsSomething ) { %&gt;

    &lt;%@ Register src=&quot;~/Sidebar.ascx&quot; tagname=&quot;SiteSidebar&quot; tagprefix=&quot;MySite&quot; %&gt;
    &lt;MySite:SiteSidebar runat=&quot;server&quot; /&gt;

&lt;% } %&gt;
</pre>
<p>
If you want to save yourself hours of grief, don&#8217;t do this <img src='http://www.keebler.net/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />   I wonder if this is the problem with a <a href="http://watch.muchmusic.com">certain video player</a> <img src='http://www.keebler.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>


<p>Related posts:<ol><li><a href='http://www.keebler.net/blog/2009/01/03/net-monitoring-windows-processes-from-aspx-webpage/' rel='bookmark' title='Permanent Link: .NET: Monitoring Windows processes from ASPX webpage'>.NET: Monitoring Windows processes from ASPX webpage</a> <small> I was recently working on some ScribbleLive features that...</small></li><li><a href='http://www.keebler.net/blog/2005/07/12/cojax-source-code-viewer/' rel='bookmark' title='Permanent Link: Cojax Source Code Viewer'>Cojax Source Code Viewer</a> <small> Here&#8217;s a neat Ajax code viewer for the Community...</small></li><li><a href='http://www.keebler.net/blog/2006/01/07/bar-code-clock-in-javascript/' rel='bookmark' title='Permanent Link: Bar Code Clock in Javascript'>Bar Code Clock in Javascript</a> <small> I honestly have no idea why watching this clock...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.keebler.net/blog/2008/11/30/aspx-dont-put-usercontrols-inside-of-code-blocks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>C#: Returning an array via webservice with derived classes</title>
		<link>http://www.keebler.net/blog/2008/11/20/c-returning-an-array-via-webservice-with-derived-classes/</link>
		<comments>http://www.keebler.net/blog/2008/11/20/c-returning-an-array-via-webservice-with-derived-classes/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 16:25:40 +0000</pubDate>
		<dc:creator>Jonathan</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://www.keebler.net/blog/?p=3752</guid>
		<description><![CDATA[
Here&#8217;s a neat little thing I learned today.  I was writing a WebMethod for a WebService I&#8217;m working on for ScribbleLive.  The return type is an array of Post objects.


[WebMethod]
public Post[] GetPostsSince( int ThreadId, DateTime Since )
{ ... }


But sometimes the array actually has objects of the type Comment, that is a derived [...]


Related posts:<ol><li><a href='http://www.keebler.net/blog/2009/05/02/generic-tweet-i-am-returning/' rel='bookmark' title='Permanent Link: Generic tweet: I am returning &#8230;'>Generic tweet: I am returning &#8230;</a> <small>Generic tweet: I am returning a video camera. I might...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>
Here&#8217;s a neat little thing I learned today.  I was writing a WebMethod for a WebService I&#8217;m working on for <a href="http://www.scribblelive.com">ScribbleLive</a>.  The return type is an array of Post objects.
</p>
<pre class="syntax-highlight:c#">
[WebMethod]
public Post[] GetPostsSince( int ThreadId, DateTime Since )
{ ... }
</pre>
<p>
But sometimes the array actually has objects of the type Comment, that is a derived class of Post.  When I tried tried it out, it threw this exception:</p>
<blockquote><p>System.InvalidOperationException: There was an error generating the XML document. &#8212;> System.InvalidOperationException: The type Comment was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.</p></blockquote>
<p>
The problem is that the Serializer doesn&#8217;t know about the Comment class until runtime, and it throws a tantrum.  Luckily, the fix is just to put a directive in there to make sure it knows that the Comment class may be used.
</p>
<p>
In my case, I just added the XmlInclude directive right about my Post class declaration like this:</p>
<pre class="syntax-highlight:c#">
[Serializable()]
[XmlInclude( typeof( Comment ) )]
public class Post
{ ... }
</pre>
</p>
<p>
And that did the trick!  I hope this is helpful for someone else <img src='http://www.keebler.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>


<p>Related posts:<ol><li><a href='http://www.keebler.net/blog/2009/05/02/generic-tweet-i-am-returning/' rel='bookmark' title='Permanent Link: Generic tweet: I am returning &#8230;'>Generic tweet: I am returning &#8230;</a> <small>Generic tweet: I am returning a video camera. I might...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.keebler.net/blog/2008/11/20/c-returning-an-array-via-webservice-with-derived-classes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
