<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Coding for Fun and Profit</title>
	<atom:link href="http://codingforfunandprofit.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://codingforfunandprofit.wordpress.com</link>
	<description>A blog of coding tips, tricks and shared grief and despair.</description>
	<lastBuildDate>Fri, 07 Aug 2009 00:38:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='codingforfunandprofit.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/83c3a7d5e5c40adf024fc29214ac52d7?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Coding for Fun and Profit</title>
		<link>http://codingforfunandprofit.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://codingforfunandprofit.wordpress.com/osd.xml" title="Coding for Fun and Profit" />
	<atom:link rel='hub' href='http://codingforfunandprofit.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Worth Reading: Automate, else Enforce otherwise Path of Least Resistance</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/08/07/worth-reading-automate-else-enforce-otherwise-path-of-least-resistance/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/08/07/worth-reading-automate-else-enforce-otherwise-path-of-least-resistance/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 00:24:03 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.uglybugger.org/?p=124</guid>
		<description><![CDATA[A friend and colleague, Matthew Rowan, has just spent some time formalising some of the knowledge that many developers will have grasped intuitively with respect to process management &#8211; but that many won&#8217;t have. Automate, else Enforce otherwise Path of Least Resistance. This is well worth a read as far too many companies get burdened [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=124&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A friend and colleague, Matthew Rowan, has just spent some time formalising some of the knowledge that many developers will have grasped intuitively with respect to process management &#8211; but that many won&#8217;t have.</p>
<p><a href="http://matthewrowan.spaces.live.com/blog/cns!CCB05A30BCA0FF01!2229.entry">Automate, else Enforce otherwise Path of Least Resistance</a>.</p>
<p>This is well worth a read as far too many companies get burdened with process documentation over actual workable process.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=124&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/08/07/worth-reading-automate-else-enforce-otherwise-path-of-least-resistance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>Automatically rejecting appointments in Microsoft Outlook 2007</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/07/31/automatically-rejecting-appointments-in-microsoft-outlook-2007/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/07/31/automatically-rejecting-appointments-in-microsoft-outlook-2007/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 07:20:14 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Calendar]]></category>
		<category><![CDATA[Courtesy]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[Scheduling]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2009/07/31/automatically-rejecting-appointments-in-microsoft-outlook-2007/</guid>
		<description><![CDATA[There’s a nice feature in Outlook that allows users to automatically accept appointments, and even decline conflicting appointments. Unfortunately, what it can’t do is allow you to specify specific reasons for rejecting meeting invitations. A particular pet hate of mine is when people send a meeting invitation entitled “Foo Discussions” or some such, and fail [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=121&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There’s a nice feature in Outlook that allows users to automatically accept appointments, and even decline conflicting appointments. Unfortunately, what it <em>can’t</em> do is allow you to specify specific reasons for rejecting meeting invitations.</p>
<p><a href="http://codingforfunandprofit.files.wordpress.com/2009/07/image6.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb6.png?w=242&#038;h=167" width="242" height="167"></a> </p>
<p>A particular pet hate of mine is when people send a meeting invitation entitled “Foo Discussions” or some such, and fail to specify a location or any content. It’s even more irritating when I’m trying to be a good little corporate citizen and have my calendar auto-accept appointments, but they send it ten minutes before the thing actually starts. They’re going to receive an acceptance notice (of course) but my phone’s not going to synch for a good half-hour, and there’s just no way I’m going to be there. Funnily enough, I’m not just sitting around on my backside, waiting for someone to invite me to a meeting.</p>
<blockquote><p>Oh, a meeting! How <em>exciting!</em> I’ve been waiting for one of these <em>all day!</em></p>
</blockquote>
<p>Of course, if you simply decline offending appointments manually, people tend to get offended. (Which may or may not be a good thing, depending on who it is.) A better way, however, is to automate the process.</p>
<blockquote><p>Nothing personal, old chap – my calendar just has automation rules that apply to everyone.</p>
</blockquote>
<p>The rules for getting into my calendar are simple:</p>
<ol>
<li><strong>Tell me everything I need to know about the meeting.</strong> This includes, specifically, its location. Outlook enforces pretty much everything else, but fails to enforce this one.
<li><strong>Please do me the courtesy of checking my free/busy information and <em>do not </em>attempt to trump something that’s already been organised.</strong> It shows a complete and utter disregard for my time and that of anyone with whom I’ve already agreed to meet.
<li><strong>Do me the courtesy of giving me at least 24 hours’ notice.</strong> Don’t send me a meeting request at 7pm on Monday evening for 7:30am on Tuesday morning. I’m not going to read it, and I’m not going to be there.</li>
</ol>
<p>I finally snapped today, after another imbecilic meeting request, and wrote these two quick methods. They enforce the three rules above, automatically accept the request if it passes and automatically decline otherwise. They appear to work for me; your mileage may vary. No warranties, express or implied, etc.</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">Sub</span> AutoProcessMeetingRequest(oRequest <span style="color:#0000ff;">As</span> MeetingItem)

    <span style="color:#008000;">' bail if this isn't a meeting request</span>
    <span style="color:#0000ff;">If</span> oRequest.MessageClass &lt;&gt; <span style="color:#006080;">"IPM.Schedule.Meeting.Request"</span> <span style="color:#0000ff;">Then</span> <span style="color:#0000ff;">Exit</span> <span style="color:#0000ff;">Sub</span>

    <span style="color:#0000ff;">Dim</span> oAppt <span style="color:#0000ff;">As</span> AppointmentItem
    <span style="color:#0000ff;">Set</span> oAppt = oRequest.GetAssociatedAppointment(<span style="color:#0000ff;">True</span>)

    <span style="color:#0000ff;">Dim</span> declinedReasons <span style="color:#0000ff;">As</span> <span style="color:#0000ff;">String</span>
    declinedReasons = <span style="color:#006080;">""</span>

    <span style="color:#0000ff;">If</span> (oAppt.Location = <span style="color:#006080;">""</span>) <span style="color:#0000ff;">Then</span>
        declinedReasons = declinedReasons &amp; <span style="color:#006080;">" * No location specified."</span> &amp; vbCrLf
    <span style="color:#0000ff;">End</span> <span style="color:#0000ff;">If</span>

    <span style="color:#0000ff;">If</span> (HasConflicts(oAppt)) <span style="color:#0000ff;">Then</span>
        declinedReasons = declinedReasons &amp; <span style="color:#006080;">" * It conflicts with an existing appointment."</span> &amp; vbCrLf
    <span style="color:#0000ff;">End</span> <span style="color:#0000ff;">If</span>

    <span style="color:#0000ff;">If</span> (DateTime.DateDiff(<span style="color:#006080;">"h"</span>, DateTime.Now, oAppt.Start) &lt; 24) <span style="color:#0000ff;">Then</span>
        declinedReasons = declinedReasons &amp; <span style="color:#006080;">" * The meeting's start time is too close to the current time. "</span> &amp; vbCrLf
    <span style="color:#0000ff;">End</span> <span style="color:#0000ff;">If</span>

    <span style="color:#0000ff;">Dim</span> oResponse <span style="color:#0000ff;">As</span> MeetingItem
    <span style="color:#0000ff;">If</span> (declinedReasons = <span style="color:#006080;">""</span>) <span style="color:#0000ff;">Then</span>
        <span style="color:#0000ff;">Set</span> oResponse = oAppt.Respond(olMeetingAccepted, <span style="color:#0000ff;">True</span>)
    <span style="color:#0000ff;">Else</span>
        <span style="color:#0000ff;">Set</span> oResponse = oAppt.Respond(olMeetingDeclined, <span style="color:#0000ff;">True</span>)
        oResponse.Body = _
            <span style="color:#006080;">"This meeting request has been automatically declined for the following reasons:"</span> &amp; vbCrLf &amp; _
            declinedReasons

    <span style="color:#0000ff;">End</span> <span style="color:#0000ff;">If</span>

    oResponse.Send
    oRequest.Delete

<span style="color:#0000ff;">End</span> <span style="color:#0000ff;">Sub</span>

<span style="color:#0000ff;">Function</span> HasConflicts(oAppt <span style="color:#0000ff;">As</span> AppointmentItem) <span style="color:#0000ff;">As</span> <span style="color:#0000ff;">Boolean</span>
    <span style="color:#0000ff;">Dim</span> oCalendarFolder <span style="color:#0000ff;">As</span> Folder
    <span style="color:#0000ff;">Set</span> oCalendarFolder = ThisOutlookSession.Session.GetDefaultFolder(olFolderCalendar)

    <span style="color:#0000ff;">Dim</span> apptItem <span style="color:#0000ff;">As</span> AppointmentItem

    <span style="color:#0000ff;">For</span> <span style="color:#0000ff;">Each</span> apptItem <span style="color:#0000ff;">In</span> oCalendarFolder.Items
        <span style="color:#0000ff;">If</span> ((apptItem.BusyStatus &lt;&gt; olFree) <span style="color:#0000ff;">And</span> (oAppt &lt;&gt; apptItem)) <span style="color:#0000ff;">Then</span>
            <span style="color:#0000ff;">If</span> (apptItem.Start &lt; oAppt.<span style="color:#0000ff;">End</span>) <span style="color:#0000ff;">Then</span>
                <span style="color:#008000;">' if this item starts before the given item ends, it must end before the given item starts</span>
                <span style="color:#0000ff;">If</span> (apptItem.<span style="color:#0000ff;">End</span> &gt; oAppt.Start) <span style="color:#0000ff;">Then</span>
                    HasConflicts = <span style="color:#0000ff;">True</span>
                    <span style="color:#0000ff;">Exit</span> <span style="color:#0000ff;">Function</span>
                <span style="color:#0000ff;">End</span> <span style="color:#0000ff;">If</span>
            <span style="color:#0000ff;">End</span> <span style="color:#0000ff;">If</span>
        <span style="color:#0000ff;">End</span> <span style="color:#0000ff;">If</span>
    <span style="color:#0000ff;">Next</span>

    HasConflicts = <span style="color:#0000ff;">False</span>
<span style="color:#0000ff;">End</span> <span style="color:#0000ff;">Function</span>
</pre>
</div>
<p>Just open the VBA editor from within Outlook (Alt-F11) and paste the subroutines into the ThisOutlookSession project.</p>
<p><a href="http://codingforfunandprofit.files.wordpress.com/2009/07/image7.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb7.png?w=508&#038;h=255" width="508" height="255"></a></p>
<p>Then go and create an Outlook rule that calls the AutoProcessMeetingRequest subroutine for every meeting request you receive:</p>
<p><a href="http://codingforfunandprofit.files.wordpress.com/2009/07/image8.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb8.png?w=457&#038;h=549" width="457" height="549"></a> </p>
</p>
<p>Those of your colleagues who persistently refuse to learn how to use email (an essential business tool!) will receive responses along the following lines:</p>
<p><a href="http://codingforfunandprofit.files.wordpress.com/2009/07/image9.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb9.png?w=559&#038;h=240" width="559" height="240"></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=121&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/07/31/automatically-rejecting-appointments-in-microsoft-outlook-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>

		<media:content url="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb8.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb9.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Don&#8217;t be spamming me, Windows Live</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/07/17/dont-be-spamming-me-windows-live/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/07/17/dont-be-spamming-me-windows-live/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 23:42:58 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Fail]]></category>
		<category><![CDATA[Windows Live]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2009/07/17/dont-be-spamming-me-windows-live/</guid>
		<description><![CDATA[New features are all very nice, guys, but: a) that feature’s been around for ages; b) I hate it, as does everyone I know; c) I’ve already told Messenger not to pop up the today box when I launch it, and this looks remarkably like you’re ignoring your users’ wishes for your own marketing purposes. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=106&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://codingforfunandprofit.files.wordpress.com/2009/07/image3.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb3.png?w=567&#038;h=492" width="567" height="492"></a></p>
<p>New features are all very nice, guys, but:</p>
<p>a) that feature’s been around for ages;</p>
<p>b) I hate it, as does everyone I know;</p>
<p>c) I’ve already told Messenger not to pop up the today box when I launch it, and this looks remarkably like you’re ignoring your users’ wishes for your own marketing purposes.</p>
<p>Back to Pidgin, methinks.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=106&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/07/17/dont-be-spamming-me-windows-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>

		<media:content url="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>What&#8217;s wrong with this sequence? A message to the VSTS guys:</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/07/16/whats-wrong-with-this-sequence-a-message-to-the-vsts-guys/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/07/16/whats-wrong-with-this-sequence-a-message-to-the-vsts-guys/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 08:38:28 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Source Control]]></category>
		<category><![CDATA[Fail]]></category>
		<category><![CDATA[VSTS]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2009/07/16/whats-wrong-with-this-sequence-a-message-to-the-vsts-guys/</guid>
		<description><![CDATA[Stupid Question #1: What actually constitutes a conflict? Is a conflict when two people have changed a file, or is it when two people have changed the same part of a file and VSTS needs assistance to resolve it? Every other (sane) version control system in the world interprets a conflict as the latter. Stupid [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=102&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h4>Stupid Question #1: What actually constitutes a conflict?</h4>
<p>Is a conflict when two people have changed a file, or is it when two people have changed the same <em>part</em> of a file and VSTS needs assistance to resolve it? Every other (sane) version control system in the world interprets a conflict as the latter.</p>
<p><a href="http://codingforfunandprofit.files.wordpress.com/2009/07/image.png"><img style="display:inline;border-width:0;" title="image" src="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb.png?w=501&#038;h=309" border="0" alt="image" width="501" height="309" /></a></p>
<h4>Stupid Question #2: How is it “Auto Merge” when I have to <em>tell</em> VSTS to merge?</h4>
<p><a href="http://codingforfunandprofit.files.wordpress.com/2009/07/image1.png"><img style="display:inline;border-width:0;" title="image" src="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb1.png?w=508&#038;h=316" border="0" alt="image" width="508" height="316" /></a></p>
<h4>Stupid Question #3: If VSTS could not-quite-auto-but-with-the-press-of-a-button merge, and it managed to resolve everything all by itself, <strong><em>why on earth does it pester me about non-existent conflicts all the time?!?!?</em></strong></h4>
<p><a href="http://codingforfunandprofit.files.wordpress.com/2009/07/image2.png"><img style="display:inline;border-width:0;" title="image" src="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb2.png?w=508&#038;h=307" border="0" alt="image" width="508" height="307" /></a></p>
<p>Perhaps these questions are stupid, but I most respectfully submit that the answers are stupider.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=102&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/07/16/whats-wrong-with-this-sequence-a-message-to-the-vsts-guys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>

		<media:content url="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://codingforfunandprofit.files.wordpress.com/2009/07/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Microsoft on why a memory leak isn&#8217;t really a leak</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/07/09/microsoft-on-why-a-memory-leak-isnt-really-a-leak/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/07/09/microsoft-on-why-a-memory-leak-isnt-really-a-leak/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 06:57:02 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Memory Leaks]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2009/07/09/microsoft-on-why-a-memory-leak-isnt-really-a-leak/</guid>
		<description><![CDATA[The genesis of this rant is that a colleague and I have just spent a couple of days diagnosing and fixing memory leaks (sorry, “pseudo-leaks&#8221;,” according to Microsoft, which presumably means that the memory explosion we were seeing wasn’t actually real) caused by awful, awful garbage collection in Internet Explorer. The icing on the cake [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=94&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The genesis of this rant is that a colleague and I have just spent a couple of days diagnosing and fixing memory leaks (sorry, “pseudo-leaks&#8221;,” according to Microsoft, which presumably means that the memory explosion we were seeing wasn’t actually real) caused by awful, awful garbage collection in Internet Explorer.</p>
<p>The icing on the cake was finding this article: <a href="http://msdn.microsoft.com/en-us/library/bb250448(VS.85).aspx">Understanding and Solving Internet Explorer Leak Patterns.</a> The markworthy text is this:</p>
<blockquote><p>Pseudo-leaks almost always appear on the same page during dynamic scripting operations and should rarely be visible after navigation away from the page to a blank page.</p></blockquote>
<p>In other words, Microsoft Word doesn’t leak memory either. All you have to do is close it, open it again and miraculously all the memory that it allocated and failed to release (but that somehow fails to meet the definition of “leaked”) is released.</p>
<p>The whole <em>point</em> of Internet Exploder 8 was to build an AJAX-friendly browser. The subtext went along the lines of, “Well, all those AJAX-heavy sites like GMail, Google Maps, Hotmail etc don’t perform well under IE7 and we’re losing browser market share, so let’s make a browser that <em>is</em> AJAX-friendly. But, at the same time, let’s make developers require people to navigate away from that application before any of its memory is released.”</p>
<p>We’ve just spent <em>days</em> diagnosing as many of the various ways that IE leaks memory (ways, incidentally, with which none of the other browsers seem to have problems), patching the jQuery core to cope with its idiocy and writing our own DOM garbage collection handlers to deal with it. The jQuery and GWT discussion forums reveal that these guys are having just as much pain, and for similar reasons.</p>
<p>To the IE development team: Please, please, please, guys, fix your sodding .removeChild method and everything that has <em>anything</em> to do with it. And don’t talk to me about setting .innerHTML properties either until you have a browser that doesn’t seg-fault when I do that to a table element, or when I manually break the relationship between a node and its parent. Finally, at least have the courage to confess that your browser <em>does</em> leak memory in these scenarios rather than some pathetic attempt at explaining why a leak isn’t a leak. Grr!!</p>
<p>If you want to cringe, grab the sIEve tool (see <a title="http://codingforfunandprofit.uglybugger.org/2009/07/09/memory-leak-detector-for-internet-explorer/" href="http://codingforfunandprofit.uglybugger.org/2009/07/09/memory-leak-detector-for-internet-explorer/">Memory leak detector for Internet Explorer</a> for a link) and point it at <a title="http://msdn.microsoft.com" href="http://msdn.microsoft.com">http://msdn.microsoft.com</a>. Navigate around a bit and then have a look at the number of orphan DOM nodes. Consider how many full-page reloads MSDN causes, and compare this to your own AJAX application. Weep.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=94&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/07/09/microsoft-on-why-a-memory-leak-isnt-really-a-leak/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>Memory leak detector for Internet Explorer</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/07/09/memory-leak-detector-for-internet-explorer/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/07/09/memory-leak-detector-for-internet-explorer/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 01:57:42 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.uglybugger.org/?p=92</guid>
		<description><![CDATA[I&#8217;ve been playing with Drip and sIEve in order to find some memory leaks that we&#8217;ve been encountering under Internet Exploder. Drip / IESieve, Memory leak detector for IE Internet Explorer . If you haven&#8217;t looked at your application with sIEve, you really should.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=92&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing with Drip and sIEve in order to find some memory leaks that we&#8217;ve been encountering under Internet Exploder.</p>
<p><a href="http://home.wanadoo.nl/jsrosman/">Drip / IESieve, Memory leak detector for IE Internet Explorer </a>.</p>
<p>If you haven&#8217;t looked at your application with sIEve, you really should.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=92&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/07/09/memory-leak-detector-for-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>console.log() Equivalent for Internet Explorer</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/03/11/consolelog-equivalent-for-internet-explorer/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/03/11/consolelog-equivalent-for-internet-explorer/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 05:47:39 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2009/03/11/consolelog-equivalent-for-internet-explorer/</guid>
		<description><![CDATA[There are a bunch of people out there who are fed up with the lack of a console.log() equivalent in Internet Explorer. It shouldn’t come as any surprise that I’m one of them. For anyone who’s ever tried to debug a whole bunch of JavaScript code and ended up with myriad alert(‘here’) and alert(‘here2’) calls [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=83&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are a bunch of people out there who are fed up with the lack of a console.log() equivalent in Internet Explorer. It shouldn’t come as any surprise that I’m one of them.</p>
<p>For anyone who’s ever tried to debug a whole bunch of JavaScript code and ended up with myriad alert(‘here’) and alert(‘here2’) calls just so they could see what was happening, console.log() became our friend very, very quickly. No surprise, however, that IE didn’t have it.</p>
<p>It becomes significantly more painful, however, when you’re trying to clean up JS code for the sake of performance. The usefulness of any metrics collected goes out the window once there’s user activity involved. (Besides, clicking “OK” for all those alert boxes is a royal <em>pain</em>.)</p>
<p>(Hint to the IE8 team: Your product is still in beta. You <em>must</em> have a logging call somewhere. Publish it, please. <em>Please.</em> All the other browsers of note do.)</p>
<p>There are quite a few good console.log() equivalents out there, not the least of which are <a target="_blank" href="http://icant.co.uk/sandbox/fauxconsole/">Faux Console</a> and the <a target="_blank" href="http://developer.yahoo.com/yui/logger/">Yahoo User Interface Logger Widget</a>. For extremely light-weight applications, though, there was nothing that did just what I wanted, so I wrote one. You’ll be depressed at how simple it is, and how easy it would have been for the IE team to have included this functionality at almost any point in IE’s development cycle.</p>
<p>&nbsp;</p>
<p>The JavaScript code:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">// rudimentary javascript logging to emulate console.log(). If there already exists</span>
<span style="color:#008000;">// an object named "console" (defined by most *useful* browsers :p) then we</span>
<span style="color:#008000;">// won't do anything here at all.</span>
<span style="color:#0000ff;">if</span> (<span style="color:#0000ff;">typeof</span> (console) === <span style="color:#006080;">'undefined'</span>) {

    <span style="color:#008000;">// define "console" namespace</span>
    console = <span style="color:#0000ff;">new</span> <span style="color:#0000ff;">function</span>() {
        <span style="color:#008000;">// this is the Id of the console div. It doesn't actually need to be a div,</span>
        <span style="color:#008000;">// as long as it has an innerHTML property.</span>
        <span style="color:#0000ff;">this</span>.ConsoleDivId = <span style="color:#006080;">"JavaScriptConsole"</span>;

        <span style="color:#008000;">// maintains a reference to the console output div, so that we don't have to</span>
        <span style="color:#008000;">// call document.getElementById a bunch of times.</span>
        <span style="color:#0000ff;">this</span>.ConsoleDiv = <span style="color:#0000ff;">null</span>;

        <span style="color:#008000;">// allows us to cache whether or not the console div exists, so that we can</span>
        <span style="color:#008000;">// just do an early exit from the console.log method and similar if we're not</span>
        <span style="color:#008000;">// going to put any useful output anywhere.</span>
        <span style="color:#0000ff;">this</span>.ConsoleDivExists = <span style="color:#0000ff;">null</span>;
    };

    <span style="color:#008000;">// this is an expensive (really quite expensive) string padding function. Don't use</span>
    <span style="color:#008000;">// it for large strings.  -andrewh 11/3/09</span>
    console.padString = <span style="color:#0000ff;">function</span>(s, padToLength, padCharacter) {
        <span style="color:#0000ff;">var</span> response = <span style="color:#006080;">""</span> + s;
        <span style="color:#0000ff;">while</span> (response.length &lt; padToLength) {
            response = padCharacter + response;
        }

        <span style="color:#0000ff;">return</span> response;
    }

    console.log = <span style="color:#0000ff;">function</span>(message) {

        <span style="color:#008000;">// this will be executed once, on first method invocation, to get a reference to the</span>
        <span style="color:#008000;">// output div if it exists</span>
        <span style="color:#0000ff;">if</span> (console.ConsoleDivExists == <span style="color:#0000ff;">null</span>) {
            console.ConsoleDiv = document.getElementById(console.ConsoleDivId);
            console.ConsoleDivExists = (console.ConsoleDiv != <span style="color:#0000ff;">null</span>);
        }

        <span style="color:#008000;">// only do any logging if we actually have an output div.  (Check using the cached</span>
        <span style="color:#008000;">// variable so that we don't end up with a bunch of failed calls to</span>
        <span style="color:#008000;">// document.getElementById).</span>
        <span style="color:#0000ff;">if</span> (console.ConsoleDivExists) {
            <span style="color:#0000ff;">var</span> date = <span style="color:#0000ff;">new</span> Date();
            <span style="color:#0000ff;">var</span> entireMessage =
                console.padString(date.getHours(), 2, <span style="color:#006080;">"0"</span>) + <span style="color:#006080;">":"</span> +
                console.padString(date.getMinutes(), 2, <span style="color:#006080;">"0"</span>) + <span style="color:#006080;">":"</span> +
                console.padString(date.getSeconds(), 2, <span style="color:#006080;">"0"</span>) + <span style="color:#006080;">"."</span> +
                console.padString(date.getMilliseconds(), 3, <span style="color:#006080;">"0"</span>) + <span style="color:#006080;">" "</span> + message;
            delete date;

            <span style="color:#008000;">// append the message</span>
            console.ConsoleDiv.innerHTML = console.ConsoleDiv.innerHTML + <span style="color:#006080;">"&lt;br /&gt;"</span> + entireMessage;

            <span style="color:#008000;">// scroll the div to the bottom</span>
            console.ConsoleDiv.scrollTop = console.ConsoleDiv.scrollHeight;
        }
    }
}</pre>
</div>
<p>Ideally you’d drop this into an included script file, but it’s more likely that you’ll paste it into a &lt;script&gt; tag in the header of your HTML document.</p>
<p>&nbsp;</p>
<p>The HTML that creates the DIV to contain the output:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">&lt;!--</span>
<span style="color:#008000;"> This is here for JavaScript debugging. Please use calls to console.log(message) to log to this console, as</span>
<span style="color:#008000;"> we're emulating the console.log() function that real browsers provide.  -andrewh 11/3/09</span>
<span style="color:#008000;"> --&gt;</span>
 <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">div</span> <span style="color:#ff0000;">id</span><span style="color:#0000ff;">="JavaScriptConsole"</span> <span style="color:#ff0000;">style</span><span style="color:#0000ff;">="position: absolute; bottom: 30px; left: 30px; width: 600px; height: 200px; overflow: scroll; background-color: Yellow; color: Red;"</span><span style="color:#0000ff;">&gt;</span>
     <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">a</span> <span style="color:#ff0000;">href</span><span style="color:#0000ff;">="javascript:document.getElementById('JavascriptConsole').style.visibility = 'hidden';"</span> <span style="color:#ff0000;">style</span><span style="color:#0000ff;">="float: right;"</span><span style="color:#0000ff;">&gt;</span>Close<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">a</span><span style="color:#0000ff;">&gt;</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">span</span> <span style="color:#ff0000;">style</span><span style="color:#0000ff;">="font-weight: bold;"</span><span style="color:#0000ff;">&gt;</span>JavaScript Console<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">span</span><span style="color:#0000ff;">&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span>
 <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">div</span><span style="color:#0000ff;">&gt;</span></pre>
</div>
<p>Note that this div also contains a hyperlink with JavaScript code in it to hide it.</p>
<p>&nbsp;</p>
<p>A simple hello world script to log to it:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">script</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">="text/javascript"</span><span style="color:#0000ff;">&gt;</span>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> console.log(<span style="color:#006080;">"Hello, world!"</span>);</pre>
<p><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">script</span><span style="color:#0000ff;">&gt;</span></pre>
</div>
<p>&nbsp;</p>
<p>… and finally, the output:</p>
<p><a href="http://codingforfunandprofit.files.wordpress.com/2009/03/image.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://codingforfunandprofit.files.wordpress.com/2009/03/image-thumb.png?w=244&#038;h=84" width="244" height="84"></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=83&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/03/11/consolelog-equivalent-for-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>

		<media:content url="http://codingforfunandprofit.files.wordpress.com/2009/03/image-thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Microsoft’s Azure Services Platform</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/02/17/microsofts-azure-services-platform/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/02/17/microsofts-azure-services-platform/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 10:13:55 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[Distributed]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2009/02/17/microsofts-azure-services-platform/</guid>
		<description><![CDATA[… and why you really should care. I’m sitting in a Microsoft user group meeting right now, and I am, to be honest, pretty unimpressed. Not with the presenters – they’re doing a good job – or with the presentation, which is on what should be a fascinating topic, but with the people. Sorry, Microsoft, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=77&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>… and why you really should care.</p>
<p>I’m sitting in a Microsoft user group meeting right now, and I am, to be honest, pretty unimpressed. Not with the presenters – they’re doing a good job – or with the presentation, which is on what should be a fascinating topic, but with the people. Sorry, Microsoft, but the greatest problem you face right now is not your technology; it’s pretty damn good[1]. It’s the people who are afraid of using it – who, sadly, aren’t very.</p>
<p>OK, I’m home now, so I can type properly.</p>
<p>The presentation topic was the <a href="http://www.microsoft.com/azure" target="_blank">Azure Services Platform</a>, which is Microsoft’s  answer to the Google cloud. Azure is a fascinating topic, both technically and strategically. The technical merits I’ll discuss in a minute. Strategically, however, this platform shows that Microsoft is quaking in its boots over what Google’s been doing with cloud computing, and is now trying to play catch-up. The degree of success a) remains to be seen; and b) depends upon the aforementioned people who are going to have to want to learn to use and exploit its strengths.</p>
<p>This platform gives immeasurable advantages to whomever wants them: almost infinite scalability, massive parallelism and redundancy, no more worries about server provisioning or downtime… the list goes on.</p>
<p>One of the reasons I’m so irritated is that instead of asking intelligent questions like, “How much can we scale a single computational task?” or even “How does this compare to the Google cloud in terms of speed, flexibility and response time?” people asked questions around keeping their own servers (“Can I still be woken up at 3am when a server falls over, please?”) and security (&#8220;Can I host my own database and have the platform talk to it?&#8221; or, in other words, &#8220;Can I still trust Microsoft with my unencrypted data, but nonetheless re-introduce my own single point of failure into an otherwise-well-designed system?&#8221;). Honestly.</p>
<p>I don’t want to rant, so suffice it to say this:</p>
<p>Learn about your craft. Go and sign up for the Azure CTP. Go and get your <a href="http://code.google.com/appengine/" target="_blank">Google App Engine</a> key. Read about the <a href="http://labs.google.com/papers/gfs.html" target="_blank">Google file-system</a> and <a href="http://aws.amazon.com/s3/" target="_blank">Amazon’s S3</a>. And, while you’re at it, go and re-read some Knuth and some Fowler[2], just because you should, and probably haven’t.</p>
<p>Get some enthusiasm about what you’re seeing, people. It’s brilliant. Go and learn about it. For what it’s worth, if you haven’t been hanging out for a cloud computing solution from Microsoft for a very long time, I most respectfully suggest that you might be in the wrong profession.</p>
<p> </p>
<p>[1] Except for Live Writer. What were you <em>thinking</em>, guys? Writing this post has been <em>painful</em>. I tried to screenshot the crash messages and embed them into another blog post (also in Live Writer) and it crashed, too. Fail.</p>
<p>[2] Who are they? Shame on you.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=77&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/02/17/microsofts-azure-services-platform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>#if DEBUG Considered Harmful</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/01/15/if-debug-considered-harmful/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/01/15/if-debug-considered-harmful/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 07:05:38 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Compiler Directives]]></category>
		<category><![CDATA[JIT]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2009/01/15/if-debug-considered-harmful/</guid>
		<description><![CDATA[I know, I know. Lots of people have written about this one, but nonetheless it still gets used and I feel I should add my $0.02. (That’s Australian money, by the way, so it probably works out at not very much in your own currency.) This post is specific to C#, as .NET has the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=75&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I know, I know. Lots of people have written about this one, but nonetheless it still gets used and I feel I should add my $0.02. (That’s Australian money, by the way, so it probably works out at not very much in your own currency.)</p>
<p>This post is specific to C#, as .NET has the very nice feature of code attributes, specifically the ConditionalAttribute class which allows methods to be compiled and invoked by the JIT compiler only if there’s a particular compilation variable set.</p>
<p>Consider the code below:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:310px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;height:346px;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Hello()
{
    Console.WriteLine(<span style="color:#006080;">"Hello, world!"</span>);
}

<span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Goodbye()
{
    Console.WriteLine(<span style="color:#006080;">"Goodbye, cruel world!"</span>);
}

<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> GreetTheWorld()
{
    <span style="color:#cc6633;">#if</span> DEBUG
    Hello();
    <span style="color:#cc6633;">#endif</span>

    Goodbye();
}</pre>
</div>
<p>Let’s say that we compile this in Debug mode with code analysis turned on and warnings set to errors. (We all compile with warnings == errors, right?) All is well.</p>
<p>We go to run our unit tests again in Release mode prior to check-in, so we recompile in Release mode. (Or, if we’re lazy, we just check in from our Debug build and let our build server compile and run the tests in Release mode.)</p>
<p>Oops. CA1811 violation: you have uncalled private methods in your code. Please call them if you meant to call them, or remove them if not. The FxCop engine will never notice that our #if DEBUG directive has compiled out the call to our Hello() method, so code analysis throws an error.</p>
<p>Use this one instead:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:310px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">[Conditional(<span style="color:#006080;">"DEBUG"</span>)]
<span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Hello()
{
    Console.WriteLine(<span style="color:#006080;">"Hello, world!"</span>);
}

<span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Goodbye()
{
    Console.WriteLine(<span style="color:#006080;">"Goodbye, cruel world!"</span>);
}

<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> GreetTheWorld()
{
    Hello();
    Goodbye();
}</pre>
</div>
<p>This makes the compiler <em>much</em> happier.</p>
<p>Let’s consider the first piece of code again, though, and edit it in Release mode. Perhaps we’d like to rename our methods to something more descriptive of what they do: PrintHello() and PrintGoodbye(). So, we whip out our trusty refactoring tool (^R ^R in Visual Studio) and tell it to rename our methods.</p>
<p>Here’s what we end up with (remembering that we’re in Release mode):</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:310px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> PrintHello()
{
    Console.WriteLine(<span style="color:#006080;">"Hello, world!"</span>);
}

<span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> PrintGoodbye()
{
    Console.WriteLine(<span style="color:#006080;">"Goodbye, cruel world!"</span>);
}

<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> GreetTheWorld()
{
    <span style="color:#cc6633;">#if</span> DEBUG
    Hello();
    <span style="color:#cc6633;">#endif</span>

    PrintGoodbye();
}</pre>
</div>
<p>Oh, sod. We’ve introduced a compilation error because the refactor/rename operation uses the compiled version of the code to check for symbol usage, and our call to the former Hello() method doesn’t appear in the compiled assembly because the #if DEBUG check caused it to not be compiled. We’ve left the old call to Hello() unchanged.</p>
<p>If we’d performed the same operation on the second piece of code instead, we’d be laughing.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=75&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/01/15/if-debug-considered-harmful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>Brisbane Alt.Net User Group Launched</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/01/14/brisbane-altnet-user-group-launched/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/01/14/brisbane-altnet-user-group-launched/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 02:48:50 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Brisbane]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2009/01/14/brisbane-altnet-user-group-launched/</guid>
		<description><![CDATA[The Brisbane Alt.Net User Group has launched. Check it out at Brisbane Alt.Net or, even better, turn up to the first meeting in February.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=74&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The Brisbane Alt.Net User Group has launched. Check it out at <a href="http://brisbane.ozalt.net/">Brisbane Alt.Net</a> or, even better, turn up to the first meeting in February.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=74&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/01/14/brisbane-altnet-user-group-launched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>The Windows 7 Beta Kicks Off This Week &#8211; Windows 7 Team Blog &#8211; The Windows Blog</title>
		<link>http://codingforfunandprofit.wordpress.com/2009/01/11/the-windows-7-beta-kicks-off-this-week-windows-7-team-blog-the-windows-blog/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2009/01/11/the-windows-7-beta-kicks-off-this-week-windows-7-team-blog-the-windows-blog/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 08:53:27 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Beta]]></category>
		<category><![CDATA[Download]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2009/01/11/the-windows-7-beta-kicks-off-this-week-windows-7-team-blog-the-windows-blog/</guid>
		<description><![CDATA[Just in case you missed it, the Windows 7 Beta is now available. The Windows 7 Beta Kicks Off This Week &#8211; Windows 7 Team Blog &#8211; The Windows Blog . As I&#8217;ve been officially on holidays for the last four days (yes, four days includes two days of weekend; /sigh) I haven&#8217;t fetched it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=71&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just in case you missed it, the Windows 7 Beta is now available.</p>
<p><a href="http://windowsteamblog.com/blogs/windows7/archive/2009/01/07/the-windows-7-beta-kicks-off-this-week.aspx">The Windows 7 Beta Kicks Off This Week &#8211; Windows 7 Team Blog &#8211; The Windows Blog </a>.</p>
<p>As I&#8217;ve been officially on holidays for the last four days (yes, four days includes two days of weekend; /sigh) I haven&#8217;t fetched it yet so I have no wisdom for anyone about what&#8217;s good and what&#8217;s not. Why not try it and see?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=71&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2009/01/11/the-windows-7-beta-kicks-off-this-week-windows-7-team-blog-the-windows-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>Braces in string.Format()</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/12/02/braces-in-stringformat/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/12/02/braces-in-stringformat/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 23:33:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/12/02/braces-in-stringformat/</guid>
		<description><![CDATA[I’m really quite surprised that I’ve never needed this before, but today I wanted to embed some JavaScript within a string contained in a C# class and format it using string.Format(). The problem? My JavaScript was a function declaration and therefore contained braces, but the placeholder delimiters in string.Format also use braces. The solution: braces [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=67&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’m really quite surprised that I’ve never needed this before, but today I wanted to embed some JavaScript within a string contained in a C# class and format it using string.Format().</p>
<p>The problem? My JavaScript was a function declaration and therefore contained braces, but the placeholder delimiters in string.Format also use braces.</p>
<p>The solution: braces get escaped using another brace of the same sort.</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">string</span> jsConditionalHelloWorldTemplate =
    <span style="color:#006080;">"if ({0}) {{\r\n"</span> +
    <span style="color:#006080;">"    alert('Hello, world!');"</span> +
    <span style="color:#006080;">"}}"</span> +
    <span style="color:#006080;">""</span>;

<span style="color:#0000ff;">string</span> sendToBrowser = <span style="color:#0000ff;">string</span>.Format(jsConditionalHelloWorldTemplate, <span style="color:#006080;">"true"</span>)
writer.Write(sendToBrowser);</pre>
</div>
<p>Simple, really, but not intuitive – most civilized formatters use a backslash to escape characters. Hmm.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=67&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/12/02/braces-in-stringformat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>JavaScript .cloneNode() doesn&#8217;t clone event handlers</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/11/27/javascript-clonenode-doesnt-clone-event-handlers/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/11/27/javascript-clonenode-doesnt-clone-event-handlers/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 04:54:39 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/?p=57</guid>
		<description><![CDATA[Just for the record, I hate JavaScript. It makes me feel dirty. Nonetheless, if you’re going to use a tool – even one that you hate – use it well. Here’s one that will one day bite you. Consider this code: &#60;html&#62; &#60;head&#62; &#60;script type="text/javascript"&#62; var OnLoad = function() { document.getElementById("cloneme").onclick = function() { alert("onload");}; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=57&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just for the record, I hate JavaScript. It makes me feel dirty. Nonetheless, if you’re going to use a tool – even one that you hate – use it well.</p>
<p>Here’s one that will one day bite you. Consider this code:</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&lt;html&gt;
    &lt;head&gt;
        &lt;script type=<span style="color:#006080;">"text/javascript"</span>&gt;

            <span style="color:#0000ff;">var</span> OnLoad = <span style="color:#0000ff;">function</span>() {
                document.getElementById(<span style="color:#006080;">"cloneme"</span>).onclick = <span style="color:#0000ff;">function</span>() { alert(<span style="color:#006080;">"onload"</span>);};
                document.body.appendChild(document.getElementById(<span style="color:#006080;">"cloneme"</span>).cloneNode(<span style="color:#0000ff;">true</span>));
            }

            window.attachEvent(<span style="color:#006080;">"onload"</span>, OnLoad);
        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;a id=<span style="color:#006080;">"cloneme"</span> href=<span style="color:#006080;">"javascript:alert('href');"</span>&gt;Test Hyperlink&lt;/a&gt;&lt;br /&gt;
        &lt;br /&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
</div>
<p>If you drop it into a local .html file and point a browser at it, it’ll look something like this:</p>
<p><a href="http://codingforfunandprofit.files.wordpress.com/2008/11/image1.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="Yes, I know, I used Internet Exploder for this example. I’m sorry. I’m a bad human." src="http://codingforfunandprofit.files.wordpress.com/2008/11/image-thumb1.png?w=354&#038;h=157" border="0" alt="Yes, I know, I used Internet Exploder for this example. I’m sorry. I’m a bad human." width="354" height="157" /></a></p>
<p>There <em>is</em> a catch, however: although one hyperlink is a direct clone of the other, they’re not identical.</p>
<p>If you click the first one, you’ll see the order in which the events should fire represented by two alert boxes, the first one shouting “onload” and the second “href”.</p>
<p>If you click the second one, you’ll only see the “href” message.</p>
<p>Why is this?</p>
<p>The key point to remember is that the DOM object is being cloned from its textual representation. In other words, .clone() does <em>not</em> do a deep copy; rather, it effectively just creates a new node based on the .outerHtml property of the old node. Notably, that does <em>not</em> include any event handlers that have been attached programmatically.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=57&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/11/27/javascript-clonenode-doesnt-clone-event-handlers/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>

		<media:content url="http://codingforfunandprofit.files.wordpress.com/2008/11/image-thumb1.png" medium="image">
			<media:title type="html">Yes, I know, I used Internet Exploder for this example. I’m sorry. I’m a bad human.</media:title>
		</media:content>
	</item>
		<item>
		<title>Microsoft JScript compilation error: &#8216;return&#8217; statement outside of function</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/11/25/microsoft-jscript-compilation-error-return-statement-outside-of-function/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/11/25/microsoft-jscript-compilation-error-return-statement-outside-of-function/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 07:46:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/11/25/microsoft-jscript-compilation-error-return-statement-outside-of-function/</guid>
		<description><![CDATA[I feel dirty. Oh, so dirty. Internet Exploder runs script evaluated using the JavaScript eval() function in the global scope. So what? Well, if you’re doing something silly, as I’m being obliged to do right now, such as dynamically adding and removing click handlers based on CSS attributes, fake HtmlTextWriter objects and third-party controls (over [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=20&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I feel dirty. Oh, so dirty.</p>
<p>Internet Exploder runs script evaluated using the JavaScript eval() function in the global scope.</p>
<p>So what?</p>
<p>Well, if you’re doing something silly, as I’m being obliged to do right now, such as dynamically adding and removing click handlers based on CSS attributes, fake HtmlTextWriter objects and third-party controls (over which I have no control), you’re eventually going to run into the error above.</p>
<p>Your code might look, in a very simplified form, something like this:</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">var</span> RunCrazyUnsafeScript = <span style="color:#0000ff;">function</span>(scriptToEval) {
    eval(scriptToEval);
}</pre>
</div>
<p>… and you’re probably invoking it something like this:</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">RunCrazyUnsafeScript(<span style="color:#006080;">"alert('Hello, world!');"</span>);</pre>
</div>
<p>… and by and large, this all works perfectly well. Occasionally, however, you’ll see the error above. The odds are that you’re probably doing something like this:</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">RunCrazyUnsafeScript(<span style="color:#006080;">"alert('Hello, world!'); return false;"</span>);</pre>
</div>
<p>This is perfectly legitimate in an event handler, and there are plenty of cases in which you actually <em>want</em> to return a value from evaluated code. I can’t understand why the JavaScript implementation of eval() doesn’t function more along the lines of perl, where eval() can be used to return all sorts of things, including – gasp! – the return value of the evaluated code. Wow.</p>
<p>Anyway… I’ll come to the code snippet that you can copy and paste so that you can leave this blog and go back to your own code.</p>
<p> </p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">var</span> ScriptHelpers = <span style="color:#0000ff;">function</span>() {
    <span style="color:#0000ff;">var</span> _this = <span style="color:#0000ff;">this</span>;    <span style="color:#008000;">// don't trust "this" in JS unless you *really* know what you're doing</span>

    <span style="color:#008000;">// IMPORTANT: This function is NOT thread safe. If you want to use it in a</span>
    <span style="color:#008000;">// multi-threaded application, you need to make it so. Or, preferably, fix</span>
    <span style="color:#008000;">// the code that's forcing you do use this approach at all.</span>
    _this.EvalWithReturnValue = <span style="color:#0000ff;">function</span>(scriptToEval) {
        returnValue = undefined;
        scriptToEval = expToEval.replace(<span style="color:#006080;">" return "</span>, <span style="color:#006080;">" returnValue= "</span>);    <span style="color:#008000;">// euww.. global. icky, icky, icky.  -andrewh 25/11/08</span>
        eval(scriptToEval);
        <span style="color:#0000ff;">return</span> returnValue;
    }
}

<span style="color:#0000ff;">var</span> scriptWotWeGotFromSomeBlokeInAPub = <span style="color:#006080;">"alert('Hello, world!'); return false;"</span>;
<span style="color:#0000ff;">var</span> scriptReturnValue = ScriptHelpers.EvalWithReturnValue(scriptWotWeGotFromSomeBlokeInAPub);</pre>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=20&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/11/25/microsoft-jscript-compilation-error-return-statement-outside-of-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>.NET Provider Model and Code Snippet</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/11/25/net-provider-model-and-code-snippet/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/11/25/net-provider-model-and-code-snippet/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 00:40:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Providers]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/11/25/net-provider-model-and-code-snippet/</guid>
		<description><![CDATA[While I think the .NET provider model is great as a means of codifying dependency inversion, it really irritates me that we have to create so many peripheral classes in order to use it. For example, we need to create a strongly-typed collection class that contains them all (presumably a left-over from the .NET 1.x [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=19&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While I think the .NET provider model is great as a means of codifying dependency inversion, it really irritates me that we have to create so many peripheral classes in order to use it.</p>
<p>For example, we need to create a strongly-typed collection class that contains them all (presumably a left-over from the .NET 1.x days where there were no generic types), we need a configuration section class just to support an addition to the (web|app).config file, we need the provider class itself (effectively a factory class) and we need the class(es) of which it provides instances. Oh, and the interface that our provider stuff actually provides.</p>
<p>Here’s a code snippet (<a href="http://www.google.com.au/search?hl=en&amp;rlz=1C1GGLS_enAU291&amp;q=&quot;code+snippet&quot;+&quot;visual+studio&quot;&amp;btnG=Search&amp;meta=" target="_blank">what’s a code snippet?</a>) for creating a .NET provider and all the associated paraphernalia. Unfortunately it dumps all the classes into one .cs file, but AFAIK there’s no way to get a single snippet to create multiple files. You can (and should) do that yourself, though.</p>
<p>Handily, the snippet will also generate XML for you that can be copied/pasted directly into your (web|app).config file.</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&lt;?</span><span style="color:#800000;">xml</span> <span style="color:#ff0000;">version</span><span style="color:#0000ff;">="1.0"</span> <span style="color:#ff0000;">encoding</span><span style="color:#0000ff;">="utf-8"</span> ?<span style="color:#0000ff;">&gt;</span>
<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">CodeSnippets</span>  <span style="color:#ff0000;">xmlns</span><span style="color:#0000ff;">="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"</span><span style="color:#0000ff;">&gt;</span>
  <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">CodeSnippet</span> <span style="color:#ff0000;">Format</span><span style="color:#0000ff;">="1.0.0"</span><span style="color:#0000ff;">&gt;</span>
    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Header</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Title</span><span style="color:#0000ff;">&gt;</span>provider<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Title</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Shortcut</span><span style="color:#0000ff;">&gt;</span>provider<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Shortcut</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Description</span><span style="color:#0000ff;">&gt;</span>Code snippet for a .NET Provider implementation<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Description</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Author</span><span style="color:#0000ff;">&gt;</span>Andrew Harcourt<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Author</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">SnippetTypes</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">SnippetType</span><span style="color:#0000ff;">&gt;</span>Expansion<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">SnippetType</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">SnippetTypes</span><span style="color:#0000ff;">&gt;</span>
    <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Header</span><span style="color:#0000ff;">&gt;</span>
    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Snippet</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Declarations</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Literal</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>providerName<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>The name of the provider (e.g. "Cache", "Licence").<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>Stupid<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Literal</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Literal</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>interfaceName<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>
            <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>The name of the interface that the provider will return (e.g. "ICache", "ILicence").<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>
            <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>IStupid<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Literal</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Literal</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>defaultProvider<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>The name of the default provider instance to use (e.g. "Web", "File"). The suffix "$providerName$Provider" will be added automatically.<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>Default<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Literal</span><span style="color:#0000ff;">&gt;</span>

        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Literal</span> <span style="color:#ff0000;">Editable</span><span style="color:#0000ff;">="false"</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>className<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>The type of the owning class.<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Function</span><span style="color:#0000ff;">&gt;</span>ClassName()<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Function</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>StupidClass<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Literal</span><span style="color:#0000ff;">&gt;</span>

      <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Declarations</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Code</span> <span style="color:#ff0000;">Language</span><span style="color:#0000ff;">="csharp"</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;!</span>[CDATA[using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Configuration.Provider;
using System.Diagnostics;
using System.Reflection;
using System.Web.Configuration;

#region $providerName$Provider

    [Serializable]
    public abstract class $providerName$Provider : ProviderBase
    {

        protected abstract string DefaultName { get; }
        protected abstract string DefaultDescription { get; }

        public abstract $interfaceName$ Get$providerName$();

        protected static void CheckForUnrecognizedAttributes(NameValueCollection config)
        {
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }
            if (config.Count <span style="color:#0000ff;">&gt;</span> 0)
            {
                string attr = config.GetKey(0);
                if (!string.IsNullOrEmpty(attr))
                {
                    throw new ProviderException("Unrecognized attribute: " + attr);
                }
            }
        }

        protected string VerifyInitParams(NameValueCollection config, string name)
        {
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }

            if (string.IsNullOrEmpty(name))
            {
                name = DefaultName;
            }

            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", DefaultDescription);
            }

            return name;
        }
    }

#endregion

#region $defaultProvider$$providerName$Provider

    public class $defaultProvider$$providerName$Provider : $providerName$$end$Provider  //TODO Implement abstract class "$providerName$$end$Provider"
    {
        //TODO Add or merge the following into your (web|app).config file.
        /*
        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configuration</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span>
            <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">="$providerName$ProviderService"</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">="FULL_NAMESPACE_HERE.$providerName$ProviderSection, ASSEMBLY_NAME_HERE"</span> <span style="color:#0000ff;">/&gt;</span>
          <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span>

          <span style="color:#0000ff;">&lt;</span>$providerName$ProviderService defaultProvider="$defaultProvider$$providerName$Provider"<span style="color:#0000ff;">&gt;</span>
            <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">providers</span><span style="color:#0000ff;">&gt;</span>
              <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">clear</span> <span style="color:#0000ff;">/&gt;</span>
              <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">="$defaultProvider$$providerName$Provider"</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">="FULL_NAMESPACE_HERE.$defaultProvider$$providerName$Provider, ASSEMBLY_NAME_HERE"</span> <span style="color:#0000ff;">/&gt;</span>
            <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">providers</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;/</span>$providerName$ProviderService<span style="color:#0000ff;">&gt;</span>

        <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configuration</span><span style="color:#0000ff;">&gt;</span>
        */
    }

#endregion

// The code below here is auto-generated and shouldn't need any manual
// editing unless you want to do interesting stuff.  -andrewh 18/9/08

#region $providerName$ProviderSection

    [Obfuscation(Feature = "renaming", Exclude = true, ApplyToMembers = false)]
    public class $providerName$ProviderSection : ConfigurationSection
    {
        [ConfigurationProperty("providers")]
        public ProviderSettingsCollection Providers
        {
            get { return (ProviderSettingsCollection)base["providers"]; }
        }

        [StringValidator(MinLength = 1)]
        [ConfigurationProperty("defaultProvider", DefaultValue = "$defaultProvider$$providerName$Provider")]
        public string DefaultProvider
        {
            get { return (string)base["defaultProvider"]; }
            set { base["defaultProvider"] = value; }
        }
    }

#endregion

#region $providerName$ProviderService

    [Serializable]
    public class $providerName$ProviderService
    {
        private static $interfaceName$ _instance;
        private static $providerName$Provider _provider;
        private static $providerName$ProviderCollection _providers;
        private static object _lock = new object();

        public static $providerName$Provider Provider
        {
            get { return _provider; }
        }

        public static $providerName$ProviderCollection Providers
        {
            get {
              LoadProviders();
              return _providers;
            }
        }

        public static $interfaceName$ $providerName$
        {
            get
            {
                if (_instance == null)
                {
                    _instance = LoadInstance();
                }

                return _instance;
            }
        }

        private static $interfaceName$ LoadInstance()
        {
            LoadProviders();
            $interfaceName$ instance = _provider.Get$providerName$();

            // if the default provider fails, try the others
            if (instance == null)
            {
                foreach ($providerName$Provider p in _providers)
                {
                    if (p != _provider) // don't retry the default one
                    {
                        instance = p.Get$providerName$();
                        if (instance != null) // success?
                        {
                            _provider = p;
                            break;
                        }
                    }
                }
            }

            Debug.Assert(instance != null);
            return instance;
        }

        private static void LoadProviders()
        {
            if (null == _provider)
            {
                lock (_lock)
                {
                    // do this again to make sure _provider is still null
                    if (null == _provider)
                    {
                        $providerName$ProviderSection section = LoadAndVerifyProviderSection();
                        BuildProviderCollection(section);
                    }
                }
            }
        }

        private static void BuildProviderCollection($providerName$ProviderSection section)
        {
            _providers = new $providerName$ProviderCollection();
            ProvidersHelper.InstantiateProviders(section.Providers, _providers, typeof($providerName$Provider));

            if (_providers.Count == 0)
            {
                throw new ProviderException("No providers instantiated");
            }

            _provider = _providers[section.DefaultProvider];
            if (null == _provider)
            {
                throw new ProviderException("Unable to load provider");
            }
        }

        private static $providerName$ProviderSection LoadAndVerifyProviderSection()
        {
            // fetch the section from the application's configuration file
            $providerName$ProviderSection section = ($providerName$ProviderSection)ConfigurationManager.GetSection("$providerName$ProviderService");
            if (section == null)
            {
                throw new ProviderException("$providerName$ProviderService section missing from (web|app).config");
            }

            return section;
        }
    }

#endregion

#region $providerName$ProviderCollection

    [Serializable]
    public class $providerName$ProviderCollection : ProviderCollection
    {
        public new $providerName$Provider this[string name]
        {
            get { return ($providerName$Provider)base[name]; }
        }

        public override void Add(ProviderBase provider)
        {
            if (null == provider)
            {
                throw new ArgumentNullException("provider");
            }

            if (!(provider is $providerName$Provider))
            {
                throw new ArgumentException("Invalid provider type", "provider");
            }

            base.Add(provider);
        }
    }

#endregion
]]<span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Code</span><span style="color:#0000ff;">&gt;</span>
    <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Snippet</span><span style="color:#0000ff;">&gt;</span>
  <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">CodeSnippet</span><span style="color:#0000ff;">&gt;</span>
<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">CodeSnippets</span><span style="color:#0000ff;">&gt;</span></pre>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=19&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/11/25/net-provider-model-and-code-snippet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>I&#8217;m in love with jQuery</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/11/25/i%e2%80%99m-in-love-with-jquery%e2%80%a6/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/11/25/i%e2%80%99m-in-love-with-jquery%e2%80%a6/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 00:28:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/11/25/i%e2%80%99m-in-love-with-jquery%e2%80%a6/</guid>
		<description><![CDATA[What more need I say? jQuery is making my life bearable. From Simon Willison’s blog:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=18&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What more need I say? jQuery is making my life bearable.</p>
<p>From <a href="http://simonwillison.net/2007/Aug/15/jquery/" target="_blank">Simon Willison’s blog</a>:</p>
<p><a href="http://lh6.ggpht.com/_RlpLqbhdTdM/SStGrxtLUQI/AAAAAAAAZ8M/i_JpfhVstTs/s1600-h/image%5B5%5D.png"><img style="display:inline;border-width:0;" title="image" src="http://lh4.ggpht.com/_RlpLqbhdTdM/SStGtnp6vZI/AAAAAAAAZ8U/v6MQlUSzHZQ/image_thumb%5B1%5D.png?imgmax=800" border="0" alt="image" width="244" height="212" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=18&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/11/25/i%e2%80%99m-in-love-with-jquery%e2%80%a6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>

		<media:content url="http://lh4.ggpht.com/_RlpLqbhdTdM/SStGtnp6vZI/AAAAAAAAZ8U/v6MQlUSzHZQ/image_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>IE8 JavaScript Profiling</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/11/21/ie8-javascript-profiling/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/11/21/ie8-javascript-profiling/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 01:22:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Profiling]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/11/21/ie8-javascript-profiling/</guid>
		<description><![CDATA[If you haven’t played with it yet, IE8’s JS profiling is awesome. Happy, happy, joy, joy and all that. Just don’t look at the actual execution times below, or you’ll cry (as I am :’( ).<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=17&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you haven’t played with it yet, IE8’s JS profiling is awesome. Happy, happy, joy, joy and all that.</p>
<p>Just don’t look at the actual execution times below, or you’ll cry (as I am :’( ).</p>
<p><a href="http://lh3.ggpht.com/_RlpLqbhdTdM/SSYNQUIL3BI/AAAAAAAAZtU/mAjey6t3BBE/s1600-h/clip_image002%5B7%5D.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image002" src="http://lh5.ggpht.com/_RlpLqbhdTdM/SSYNR-pbqDI/AAAAAAAAZtc/4dIAtGgjeUc/clip_image002_thumb%5B4%5D.jpg?imgmax=800" border="0" alt="clip_image002" width="406" height="104" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=17&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/11/21/ie8-javascript-profiling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>

		<media:content url="http://lh5.ggpht.com/_RlpLqbhdTdM/SSYNR-pbqDI/AAAAAAAAZtc/4dIAtGgjeUc/clip_image002_thumb%5B4%5D.jpg?imgmax=800" medium="image">
			<media:title type="html">clip_image002</media:title>
		</media:content>
	</item>
		<item>
		<title>Code Analysis Rule for Parameter Checking</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/11/12/code-analysis-rule-for-parameter-checking/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/11/12/code-analysis-rule-for-parameter-checking/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 07:15:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Analysis]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/11/12/code-analysis-rule-for-parameter-checking/</guid>
		<description><![CDATA[I know, I know. Everyone’s a gun coder, and nobody ever forgets to check the inputs to their public methods &#8211; in the same way as no coder ever makes a mistake, right? Which suggests that all bugs are deliberate… Anyway, to the point. Below is a code analysis rule (don’t ask me what a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=16&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I know, I know. Everyone’s a gun coder, and nobody ever forgets to check the inputs to their public methods &#8211; in the same way as no coder ever makes a mistake, right? Which suggests that all bugs are deliberate…</p>
<p>Anyway, to the point. Below is a code analysis rule (don’t ask me what a CA rule is; <a href="http://www.google.com.au/search?hl=en&amp;rlz=1C1GGLS_enAU291&amp;q=code+analysis+rules&amp;btnG=Search&amp;meta=" target="_blank">ask Google</a>) to encourage developers to check all parameters to their public methods.</p>
<p>It’s not the complete rule; you’ll need your own BaseRule class and XML rule definition file, but if you’re competent enough to write these rules in general then you’re competent enough to find examples of those elsewhere.</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">internal</span> <span style="color:#0000ff;">class</span> EnforceArgumentChecking : BaseRule
{
    <span style="color:#cc6633;">#region</span> Constructors

    <span style="color:#0000ff;">public</span> EnforceArgumentChecking()
        : <span style="color:#0000ff;">base</span>(<span style="color:#0000ff;">typeof</span>(EnforceArgumentChecking).Name) { }

    <span style="color:#cc6633;">#endregion</span>

    <span style="color:#cc6633;">#region</span> Public Properties

    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">override</span> Microsoft.FxCop.Sdk.TargetVisibilities TargetVisibility
    {
        get
        {
            <span style="color:#0000ff;">return</span> TargetVisibilities.All;
        }
    }

    <span style="color:#cc6633;">#endregion</span>

    <span style="color:#cc6633;">#region</span> Public Methods

    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">override</span> ProblemCollection Check(Member member)
    {
        ProblemCollection problems = <span style="color:#0000ff;">new</span> ProblemCollection();

        Method method = member <span style="color:#0000ff;">as</span> Method;
        <span style="color:#0000ff;">if</span> (ShouldCheck(method))
        {
            Dictionary&lt;<span style="color:#0000ff;">string</span>, <span style="color:#0000ff;">int</span>&gt; parameterExceptions = GetParameterExceptionCounts(method);

            <span style="color:#008000;">// require that each parameter have at least one /Argument.*Exception/ associated with it</span>
            <span style="color:#0000ff;">foreach</span> (<span style="color:#0000ff;">string</span> parameterName <span style="color:#0000ff;">in</span> GetParametersToCheck(method))
            {
                <span style="color:#008000;">// if there's no count for this parameter name, or the count's less than one, we have a problem.</span>
                <span style="color:#0000ff;">if</span> ((!parameterExceptions.ContainsKey(parameterName)) || ((parameterExceptions[parameterName] &lt; 1)))
                {
                    Resolution resolution = GetNamedResolution(<span style="color:#006080;">"ArgumentNotChecked"</span>, parameterName, method.Name.ToString());
                    problems.Add(<span style="color:#0000ff;">new</span> Problem(resolution));
                }
            }
        }

        <span style="color:#0000ff;">return</span> problems;
    }

    <span style="color:#cc6633;">#endregion</span>

    <span style="color:#cc6633;">#region</span> Helper Methods

    <span style="color:#008000;">/// &lt;summary&gt;</span>
    <span style="color:#008000;">/// Gets a list of the parameter names to check. This will return all parameter names except those</span>
    <span style="color:#008000;">/// that have a Zap.Attributes.SuspressParameterCheck entry for that individual parameter.</span>
    <span style="color:#008000;">/// &lt;/summary&gt;</span>
    <span style="color:#008000;">/// &lt;param name="method"&gt;The method whose parameter collection to scan.&lt;/param&gt;</span>
    <span style="color:#0000ff;">private</span> IEnumerable&lt;<span style="color:#0000ff;">string</span>&gt; GetParametersToCheck(Method method)
    {
        List&lt;<span style="color:#0000ff;">string</span>&gt; parametersToIgnore = <span style="color:#0000ff;">new</span> List&lt;<span style="color:#0000ff;">string</span>&gt;();

        <span style="color:#0000ff;">foreach</span> (AttributeNode attr <span style="color:#0000ff;">in</span> method.Attributes)
        {
            <span style="color:#0000ff;">if</span> (attr.Type.FullName.Equals(<span style="color:#006080;">"Zap.Attributes.SuppressParameterCheck"</span>))
            {
                Expression paramName = attr.GetPositionalArgument(0);
                Expression justification = attr.GetPositionalArgument(1);

                <span style="color:#0000ff;">if</span> (!<span style="color:#0000ff;">string</span>.IsNullOrEmpty(justification.ToString()))
                {
                    parametersToIgnore.Add(paramName.ToString());
                }
            }
        }

        <span style="color:#0000ff;">foreach</span> (Parameter p <span style="color:#0000ff;">in</span> method.Parameters)
        {
            <span style="color:#0000ff;">string</span> paramName = p.Name.ToString();

            <span style="color:#0000ff;">if</span> (parametersToIgnore.Contains(paramName))
            {
                <span style="color:#0000ff;">continue</span>;
            }

            <span style="color:#0000ff;">yield</span> <span style="color:#0000ff;">return</span> paramName;
        }
    }

    <span style="color:#008000;">/// &lt;summary&gt;</span>
    <span style="color:#008000;">/// Decides whether we should apply this rule to the given method.</span>
    <span style="color:#008000;">/// &lt;/summary&gt;</span>
    <span style="color:#008000;">/// &lt;param name="method"&gt;The method.&lt;/param&gt;</span>
    <span style="color:#008000;">/// &lt;returns&gt;False if the method is null, non-public, an interface or abstract method, a public property setter; true otherwise.&lt;/returns&gt;</span>
    <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">bool</span> ShouldCheck(Method method)
    {
        <span style="color:#0000ff;">if</span> (method == <span style="color:#0000ff;">null</span>) { <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">false</span>; }

        <span style="color:#0000ff;">if</span> (!method.IsPublic) { <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">false</span>; }

        <span style="color:#008000;">// this will catch methods that are defined as either abstract or interface methods</span>
        <span style="color:#0000ff;">if</span> (method.IsAbstract) { <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">false</span>; }

        <span style="color:#0000ff;">if</span> (method.IsAccessor) { <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">false</span>; }

        <span style="color:#008000;">// we don't check operators - they all generally call the AreEqual, Add, Append or other named methods anyway - and they're almost</span>
        <span style="color:#008000;">// always overloads.</span>
        <span style="color:#0000ff;">if</span> (method.Name.ToString().StartsWith(<span style="color:#006080;">"op_"</span>, StringComparison.Ordinal)) { <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">false</span>; }

        <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">true</span>;
    }

    <span style="color:#008000;">/// &lt;summary&gt;</span>
    <span style="color:#008000;">/// Looks for the creation of instances of /Argument.*Exception/ and counts them for each parameter on the method.</span>
    <span style="color:#008000;">/// &lt;/summary&gt;</span>
    <span style="color:#008000;">/// &lt;returns&gt;A dictionary mapping the parameter name to the number of /Argument.*Exception/ thrown against that parameter.&lt;/returns&gt;</span>
    <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> Dictionary&lt;<span style="color:#0000ff;">string</span>, <span style="color:#0000ff;">int</span>&gt; GetParameterExceptionCounts(Method method)
    {
        Dictionary&lt;<span style="color:#0000ff;">string</span>, <span style="color:#0000ff;">int</span>&gt; exceptionsThrownOnParameters = <span style="color:#0000ff;">new</span> Dictionary&lt;<span style="color:#0000ff;">string</span>, <span style="color:#0000ff;">int</span>&gt;();

        <span style="color:#008000;">// count the exceptions thrown on each parameter.</span>
        <span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">int</span> i = 2; i &lt; method.Instructions.Count; i++) <span style="color:#008000;">// start from 2 because it's pretty much impossible to throw a useful exception before this.</span>
        {
            Instruction instruction = method.Instructions[i];

            <span style="color:#008000;">// are creating a new Argument*.Exception object?</span>
            <span style="color:#0000ff;">if</span> (instruction.OpCode == OpCode.Newobj)
            {
                InstanceInitializer initializer = (InstanceInitializer)instruction.Value;
                <span style="color:#0000ff;">if</span> (Regex.IsMatch(initializer.FullName, <span style="color:#006080;">"Argument.*Exception"</span>))
                {
                    <span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">int</span> paramIdx = 0; paramIdx &lt; initializer.Parameters.Count; paramIdx++)
                    {
                        Parameter p = initializer.Parameters[paramIdx];
                        <span style="color:#0000ff;">if</span> (p.Name.ToString().Equals(<span style="color:#006080;">"paramName"</span>))
                        {
                            <span style="color:#0000ff;">int</span> paramOffset = initializer.Parameters.Count - paramIdx;

                            Instruction loadStringInstruction = method.Instructions[i - paramOffset];
                            <span style="color:#0000ff;">if</span> (loadStringInstruction.OpCode == OpCode.Ldstr)
                            {
                                <span style="color:#0000ff;">string</span> parameterValue = loadStringInstruction.Value.ToString();

                                <span style="color:#0000ff;">if</span> (!exceptionsThrownOnParameters.ContainsKey(parameterValue))
                                {
                                    exceptionsThrownOnParameters[parameterValue] = 1;
                                }
                                <span style="color:#0000ff;">else</span>
                                {
                                    exceptionsThrownOnParameters[parameterValue]++;
                                }
                            }
                        }
                    }
                }
            }
        }

        <span style="color:#0000ff;">return</span> exceptionsThrownOnParameters;
    }

    <span style="color:#cc6633;">#endregion</span>

}</pre>
</div>
<p>Hand in hand with this rule is a code attribute that allows the programmer to suppress warnings on individual method parameters, rather than just suppressing the entire rule for a particular method:</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">[AttributeUsage(AttributeTargets.Method, Inherited = <span style="color:#0000ff;">false</span>, AllowMultiple = <span style="color:#0000ff;">true</span>)]
<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">sealed</span> <span style="color:#0000ff;">class</span> SuppressParameterCheck : Attribute
{
    <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> _parameterName;
    <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> _justification;

    <span style="color:#0000ff;">public</span> SuppressParameterCheck(<span style="color:#0000ff;">string</span> parameterName, <span style="color:#0000ff;">string</span> justification)
    {
        <span style="color:#0000ff;">if</span> ((<span style="color:#0000ff;">string</span>.IsNullOrEmpty(justification)) || (justification.Length &lt; 10))
        {
            <span style="color:#0000ff;">throw</span> <span style="color:#0000ff;">new</span> ArgumentNullException(<span style="color:#006080;">"justification"</span>, <span style="color:#006080;">"If you're going to suppress a parameter check, you MUST MUST MUST give a reason."</span>);
        }

        _parameterName = parameterName;
        _justification = justification;
    }

    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> ParameterName
    {
        get { <span style="color:#0000ff;">return</span> _parameterName; }
    }

    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> Justification
    {
        get { <span style="color:#0000ff;">return</span> _justification; }
    }
}</pre>
</div>
<p>And an example of how to use the SuppressParameterCheck attribute:</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Insert(<span style="color:#0000ff;">string</span> key, <span style="color:#0000ff;">object</span> <span style="color:#0000ff;">value</span>)
{
    <span style="color:#cc6633;">#region</span> Argument Checking

    <span style="color:#cc6633;">#region</span> Argument Check <span style="color:#0000ff;">for</span> <span style="color:#006080;">"key"</span>

    <span style="color:#0000ff;">if</span> (<span style="color:#0000ff;">string</span>.IsNullOrEmpty(key))
    {
        <span style="color:#0000ff;">throw</span> <span style="color:#0000ff;">new</span> ArgumentNullException(<span style="color:#006080;">"key"</span>);
    }

    <span style="color:#cc6633;">#endregion</span>

    <span style="color:#cc6633;">#region</span> Argument Check <span style="color:#0000ff;">for</span> <span style="color:#006080;">"value"</span>

    <span style="color:#0000ff;">if</span> (<span style="color:#0000ff;">value</span> == <span style="color:#0000ff;">null</span>)
    {
        <span style="color:#0000ff;">throw</span> <span style="color:#0000ff;">new</span> ArgumentNullException(<span style="color:#006080;">"value"</span>);
    }
    <span style="color:#cc6633;">#endregion</span>

    <span style="color:#cc6633;">#endregion</span>

    <span style="color:#008000;">// Accept the object, but don't cache it.</span>
}

[SuppressParameterCheck(<span style="color:#006080;">"key"</span>, <span style="color:#006080;">"This will be checked in a called method."</span>)]
[SuppressParameterCheck(<span style="color:#006080;">"value"</span>, <span style="color:#006080;">"This will be checked in a called method."</span>)]
<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Insert(<span style="color:#0000ff;">string</span> key, <span style="color:#0000ff;">object</span> <span style="color:#0000ff;">value</span>, CacheExpireType expireType)
{
    Insert(key, <span style="color:#0000ff;">value</span>);    <span style="color:#008000;">// Accept the object, but don't cache it.</span>
}</pre>
</div>
<p>Of course, it goes without saying that you’re compiling with warnings == errors, right? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=16&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/11/12/code-analysis-rule-for-parameter-checking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>Windows Mobile Error 0x8503001c</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/10/09/windows-mobile-error-0x8503001c/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/10/09/windows-mobile-error-0x8503001c/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 01:25:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/10/09/windows-mobile-error-0x8503001c/</guid>
		<description><![CDATA[OK, the entire point of this blog post is to save some other poor sod from the pain that I&#8217;ve just been through. If you have a Windows Mobile device and get synchronization error 0x8503001c, your life is close to over. Trust me. You can delete and re-create the sync partnerships between your PC and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=15&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>OK, the entire point of this blog post is to save some other poor sod from the pain that I&#8217;ve just been through.</p>
<p>If you have a Windows Mobile device and get synchronization error 0x8503001c, your life is close to over. Trust me.</p>
<p>You can delete and re-create the sync partnerships between your PC and your Windows Mobile device as many times as you want, with whatever permutations of synchronization settings you choose, but it&#8217;s not likely to help. Try it anyway, but don&#8217;t waste too much time on it.</p>
<p>What you&#8217;re going to do, at some point after you&#8217;ve realized that it&#8217;s all hopeless, is reset everything to factory defaults and start over.</p>
<p>The first tool you&#8217;ll want is Dotfred&#8217;s PIM Backup tool, available at <a href="http://www.dotfred.net/" target="_blank">http://www.dotfred.net/</a>. Get it and back your device up (NOT to your device memory!).</p>
<p>Reset your device to factory defaults. On my Dopod you hold both of the multi-function buttons (the &#8220;-&#8221; buttons) while poking the reset button with your stylus. Press the Send button when it prompts you to confirm. Yours is probably different.</p>
<p>Re-create the sync relationship between your phone and your PC.</p>
<p>Re-sync everything.</p>
<p>Restore your backup.</p>
<p>Cry.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=15&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/10/09/windows-mobile-error-0x8503001c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>The Value of Check-In Policies</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/08/29/the-value-of-check-in-policies/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/08/29/the-value-of-check-in-policies/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 06:10:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Source Control]]></category>
		<category><![CDATA[Code Analysis]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/08/29/the-value-of-check-in-policies/</guid>
		<description><![CDATA[See? Now isn’t everyone glad that we have check-in policies that search for words like this? http://thedailywtf.com/Articles/We-Burned-the-Poop.aspx<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=14&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>See? Now isn’t everyone glad that we have check-in policies that search for words like this? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://thedailywtf.com/Articles/We-Burned-the-Poop.aspx" target="_blank">http://thedailywtf.com/Articles/We-Burned-the-Poop.aspx</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=14&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/08/29/the-value-of-check-in-policies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>public property != public variable</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/08/27/public-property-public-variable/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/08/27/public-property-public-variable/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 06:29:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/08/27/public-property-public-variable/</guid>
		<description><![CDATA[Here’s a particularly nasty gotcha that new .NET developers should be aware of. It should go without saying, but nonetheless it appears that it does need to be said. Hmph. The sordid details are not included here to preserve the dignity of the guilty parties, but basically it boils down to: a property getter/setter is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=13&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here’s a particularly nasty gotcha that new .NET developers should be aware of. It <em>should </em>go without saying, but nonetheless it appears that it <em>does</em> need to be said. Hmph.</p>
<p>The sordid details are not included here to preserve the dignity of the guilty parties, but basically it boils down to: a property getter/setter is NOT the same as a public instance variable.</p>
<p>In other words, you are never <em>guaranteed</em> that the value you put in will be the value you get back. Consider the following:</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">this</span>.Foo = <span style="color:#006080;">"Hello, world!"</span>;
Debug.Assert(<span style="color:#0000ff;">this</span>.Foo.Equals(<span style="color:#006080;">"Hello, world!"</span>);</pre>
</div>
<p>If I were evil (or just incompetent, as the developers of certain pieces of code I’ve had to deal with recently were), my definition of Foo could be as below:</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> _foo;
<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> Foo
{
    get
    {
        <span style="color:#0000ff;">return</span> _foo;
    }
    set
    {
        Trace.WriteLine(<span style="color:#006080;">"The caller asked me to store '{0}', but I'm going to drop it on the floor instead. &lt;snigger /&gt;"</span>.FormatWith(<span style="color:#0000ff;">value</span>));
    }
}</pre>
</div>
<p>As I said, this is an elementary distinction (and a trivial example) but do <em>not not not</em> assume that just because you’ve asked a setter to store a value that you’ll get the same value back from the getter. You <em>should</em>, but “should” is the most over-used word in this industry.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=13&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/08/27/public-property-public-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>JavaScript Code Re-Use in Microsoft CRM</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/07/25/javascript-code-re-use-in-microsoft-crm/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/07/25/javascript-code-re-use-in-microsoft-crm/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 06:22:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/07/25/javascript-code-re-use-in-microsoft-crm/</guid>
		<description><![CDATA[Microsoft’s CRM tool offers some pretty powerful JavaScript event hooks. One thing it doesn’t appear to offer, however, is a way to import a library of JS functions and re-use them across different event handlers. For example, if one wanted to display a “Hello, world!” message whenever several different attributes were changed, the conventional approach [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=12&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Microsoft’s CRM tool offers some pretty powerful JavaScript event hooks. One thing it doesn’t appear to offer, however, is a way to import a library of JS functions and re-use them across different event handlers.</p>
<p>For example, if one wanted to display a “Hello, world!” message whenever several different attributes were changed, the conventional approach would be to embed the call to alert() in each of the event handlers. Obviously, for such a simple example, this isn’t such a big deal, but for more sophisticated logic it becomes unwieldy very, very rapidly.</p>
<p>One common approach is to use externally-referenced script files. Great, but imagine the horror when you suddenly discover that your system administrator has been religiously backing up your CRM server for the last six years, but hasn’t backed up the web server from which you were serving your scripts… We still have the problem of how to reference them, too.</p>
<p>Variable declarations in JavaScript (evilly) default to global. What you can do to exploit this, however, is to declare a global function pointer from within an OnLoad event handler as follows:</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">// This is the OnLoad event handler provided by CRM</span>
<span style="color:#0000ff;">function</span> OnLoad() {
    <span style="color:#008000;">// This is the function that we want to make</span>
    <span style="color:#008000;">// available globally. Note the lack of a</span>
    <span style="color:#008000;">// "var" declaration.</span>
    helloWorldFunction = <span style="color:#0000ff;">function</span>() {
        alert(<span style="color:#006080;">"Hello, world!"</span>);
    }
}</pre>
</div>
<p>Then, in your event handler for other controls on the page, you can re-use that global variable:</p>
<div style="line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">// This is the OnChange event handler provided by CRM</span>
<span style="color:#0000ff;">function</span> OnChange() {
    <span style="color:#008000;">// ... and here's the one we prepared earlier.</span>
    helloWorldFunction();
}</pre>
</div>
<p>… and Bob’s your father’s creepy brother, you have code reuse with no external dependencies.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=12&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/07/25/javascript-code-re-use-in-microsoft-crm/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>Writing Good Unit Tests</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/07/03/writing-good-unit-tests/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/07/03/writing-good-unit-tests/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 23:42:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Unit Tests]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/07/03/writing-good-unit-tests/</guid>
		<description><![CDATA[Writing Unit Tests Why do we write unit tests? Improve code quality Fewer reported defects Make checking code faster Tell us when we&#8217;ve broken something Tell us when our work is done Allow others to check our code Encourage modular design Keep behaviour constant during refactoring Functions as a spec (think TDD) The law of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=11&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Writing Unit Tests</strong></p>
<ul>
<li>Why do we write unit tests?
<ul>
<li>Improve code quality</li>
<li>Fewer reported defects</li>
<li>Make checking code faster</li>
<li>Tell us when we&#8217;ve broken something</li>
<li>Tell us when our work is done</li>
<li>Allow others to check our code</li>
<li>Encourage modular design</li>
<li>Keep behaviour constant during refactoring Functions as a spec (think TDD)</li>
</ul>
</li>
<li>The law of diminishing returns most definitely applies here
<ul>
<li>Testing everything is infeasible. Don&#8217;t be unrealistic.</li>
<li>70% code coverage is actually pretty decent for most classes.</li>
<li>First, test the common stuff.</li>
<li>Next, test the common exception-case stuff.</li>
<li>Then test the critical stuff.</li>
<li>Add other tests as appropriate.</li>
</ul>
</li>
<li>When to write a unit test
<ul>
<li>Use a unit test to provide a framework for writing your code</li>
<li>If you find yourself running up an entire application more than once or twice to test a particular</li>
<li>method you&#8217;ve written, wrap it in a unit test and use that test to invoke it directly</li>
<li>^R ^T is your friend</li>
<li>When someone comes to you with a bug report, write a test to reproduce the bug.</li>
</ul>
</li>
</ul>
<p><strong>Key Principles for Unit Tests</strong></p>
<ul>
<li>Each and every test must be able to be run in isolation
<ul>
<li>Tests should the environment up for themselves and clean up afterwards
<ul>
<li>Use your ClassInitialize, ClassCleanup, TestInitialize and TestCleanup attributes</li>
</ul>
</li>
<li>Tests should never rely on being executed in any particular order (that&#8217;s part of the meaning of &#8220;unit&#8221;)</li>
<li>Tests should not rely overmuch on their environment
<ul>
<li>Don&#8217;t depend on files&#8217; being anywhere</li>
<li><span style="color:#ff0000;">Never, ever, ever hard-code a path. Find a better way.</span></li>
<li><span style="color:#ff0000;">For the Zap crowd: anyone who codes &#8220;C:\Projects&#8221; into a unit test (again!) is going to get a swift kicking. Politely, of course <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></li>
</ul>
</li>
<li>If a class depends on another class that depends on another class that you can&#8217;t easily instantiate in your unit test, this suggests that your classes need refactoring. Writing tests should be easy. If your classes make it hard, fix your classes first.</li>
</ul>
</li>
<li>Tests should be cheap to write
<ul>
<li>Don&#8217;t worry about exception-handling &#8211; if an unexpected exception is thrown, the test fails. Don&#8217;t bother catching it and manually asserting failure.</li>
<li>Be as explicit as you can
<ul>
<li>Don&#8217;t allow for variations in your output unless you absolutely have to.</li>
<li>If there are going to be different outputs, ideally there should be different tests</li>
</ul>
</li>
</ul>
</li>
<li>Tests should be numerous and cheap to maintain
<ul>
<li>Each test should test one (perhaps two or three, but generally just one) behaviour</li>
<li>It&#8217;s much better to have lots of small tests that check individual functionality rather than fewer, complex tests that test many things.</li>
<li>When a test breaks, we want to know exactly where the problem is, not just that there&#8217;s a problem somewhere in a call stack seven classes deep.</li>
</ul>
</li>
<li>Tests should be disposable
<ul>
<li>When the code it tests is gone, the test should be dropped on the floor.</li>
<li>If it&#8217;s a simple, obvious test, it will be simple and obvious to identify when this should happen.</li>
</ul>
</li>
<li>Tests need not be efficient</li>
</ul>
<p><strong>Cool Stuff</strong></p>
<ul>
<li>Private Accessors
<ul>
<li>These allow you to call private methods and access private variables from another class</li>
<li>This deliberately breaks OO principles</li>
<li>Use it for testing implementation-specific stuff, but depend on concrete types when you do.</li>
</ul>
</li>
</ul>
<ul>
<li><a href="http://lh4.ggpht.com/_RlpLqbhdTdM/SSunuUIDvDI/AAAAAAAAZ-s/c92dCUHBpVA/s1600-h/clip_image001%5B3%5D.png"><img style="display:inline;border-width:0;" title="clip_image001" src="http://lh3.ggpht.com/_RlpLqbhdTdM/SSunxVMmKvI/AAAAAAAAZ-0/CtRQDDsh4JY/clip_image001_thumb.png?imgmax=800" border="0" alt="clip_image001" width="244" height="84" /></a></li>
</ul>
<ul>
<li>ASPX page testing
<ul>
<li>You can automate all sorts of stuff with respect to ASPX pages</li>
<li>Button clicks</li>
<li>Form inputs</li>
<li><a href="http://lh4.ggpht.com/_RlpLqbhdTdM/SSunzCKsgZI/AAAAAAAAZ-8/jJI7YY5cXj0/s1600-h/clip_image002%5B3%5D.png"><img style="display:inline;border-width:0;" title="clip_image002" src="http://lh4.ggpht.com/_RlpLqbhdTdM/SSun06bdiFI/AAAAAAAAZ_E/mfL-MMEJYnI/clip_image002_thumb.png?imgmax=800" border="0" alt="clip_image002" width="244" height="59" /></a></li>
<li>This does not replace regression test automation (e.g. Mercury et al), but should be used by individual developers when writing new ASPX pages and ASCX controls.</li>
<li>Don&#8217;t run the application and click stuff manually</li>
<li>Write a unit test and tell it to click stuff automatically</li>
</ul>
</li>
</ul>
<ul>
<li>Testing web service methods
<ul>
<li>The unit test framework will get confused</li>
<li>Use either a wrapper (think Adapter or Façade pattern) and/or a Strategy-pattern.</li>
</ul>
</li>
</ul>
<ul>
<li>Using the unit testing framework for integration testing
<ul>
<li>Have a couple of common-case &#8220;unit&#8221; tests that actually represent an end-to-end use case of your application.</li>
</ul>
</li>
</ul>
<p>Note for young players: if you get an invalid cast exception such as&#8230;</p>
<p>Test method Test.Zap.CubeModel.DigitalSearchTreeTest.TestInsert threw exception: System.InvalidCastException: Unable to cast object of type &#8216;Node`1[System.Char,System.Char]&#8216; to type &#8216;Node`1[System.Char,System.Char]&#8216;..</p>
<p>&#8230;it may be that your type is a nested class or similar and does not have public visibility.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=11&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/07/03/writing-good-unit-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>

		<media:content url="http://lh3.ggpht.com/_RlpLqbhdTdM/SSunxVMmKvI/AAAAAAAAZ-0/CtRQDDsh4JY/clip_image001_thumb.png?imgmax=800" medium="image">
			<media:title type="html">clip_image001</media:title>
		</media:content>

		<media:content url="http://lh4.ggpht.com/_RlpLqbhdTdM/SSun06bdiFI/AAAAAAAAZ_E/mfL-MMEJYnI/clip_image002_thumb.png?imgmax=800" medium="image">
			<media:title type="html">clip_image002</media:title>
		</media:content>
	</item>
		<item>
		<title>Code Snippet for WPF Routed Event</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/06/13/code-snippet-for-wpf-routed-event/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/06/13/code-snippet-for-wpf-routed-event/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 00:14:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/06/13/code-snippet-for-wpf-routed-event/</guid>
		<description><![CDATA[It’s useful for me. Your mileage may vary. I wouldn’t mind knowing if it’s useful for anyone else, though &#60;?xml version="1.0" encoding="utf-8" ?&#62; &#60;CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&#62; &#60;CodeSnippet Format="1.0.0"&#62; &#60;Header&#62; &#60;Title&#62;eventr&#60;/Title&#62; &#60;Shortcut&#62;eventr&#60;/Shortcut&#62; &#60;Description&#62;Code snippet for a WPF Routed Event&#60;/Description&#62; &#60;Author&#62;Andrew Harcourt&#60;/Author&#62; &#60;SnippetTypes&#62; &#60;SnippetType&#62;Expansion&#60;/SnippetType&#62; &#60;SnippetType&#62;SurroundsWith&#60;/SnippetType&#62; &#60;/SnippetTypes&#62; &#60;/Header&#62; &#60;Snippet&#62; &#60;Declarations&#62; &#60;Literal&#62; &#60;ID&#62;eventName&#60;/ID&#62; &#60;ToolTip&#62;The name of the routed property (should [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=56&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It’s useful for me. Your mileage may vary. I wouldn’t mind knowing if it’s useful for anyone else, though <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&lt;?</span><span style="color:#800000;">xml</span> <span style="color:#ff0000;">version</span><span style="color:#0000ff;">="1.0"</span> <span style="color:#ff0000;">encoding</span><span style="color:#0000ff;">="utf-8"</span> ?<span style="color:#0000ff;">&gt;</span>
<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">CodeSnippets</span>  <span style="color:#ff0000;">xmlns</span><span style="color:#0000ff;">="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"</span><span style="color:#0000ff;">&gt;</span>
  <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">CodeSnippet</span> <span style="color:#ff0000;">Format</span><span style="color:#0000ff;">="1.0.0"</span><span style="color:#0000ff;">&gt;</span>
    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Header</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Title</span><span style="color:#0000ff;">&gt;</span>eventr<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Title</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Shortcut</span><span style="color:#0000ff;">&gt;</span>eventr<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Shortcut</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Description</span><span style="color:#0000ff;">&gt;</span>Code snippet for a WPF Routed Event<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Description</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Author</span><span style="color:#0000ff;">&gt;</span>Andrew Harcourt<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Author</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">SnippetTypes</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">SnippetType</span><span style="color:#0000ff;">&gt;</span>Expansion<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">SnippetType</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">SnippetType</span><span style="color:#0000ff;">&gt;</span>SurroundsWith<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">SnippetType</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">SnippetTypes</span><span style="color:#0000ff;">&gt;</span>
    <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Header</span><span style="color:#0000ff;">&gt;</span>
    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Snippet</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Declarations</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Literal</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>eventName<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>The name of the routed property (should *end* in ...Event).<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>Stupid<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Literal</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Literal</span> <span style="color:#ff0000;">Editable</span><span style="color:#0000ff;">="false"</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>className<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ID</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>The type of the owning class.<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ToolTip</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Function</span><span style="color:#0000ff;">&gt;</span>ClassName()<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Function</span><span style="color:#0000ff;">&gt;</span>
          <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>StupidClass<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Default</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Literal</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Declarations</span><span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Code</span> <span style="color:#ff0000;">Language</span><span style="color:#0000ff;">="csharp"</span><span style="color:#0000ff;">&gt;</span>
        <span style="color:#0000ff;">&lt;!</span>[CDATA[#region $eventName$ Routed Event

        public static readonly RoutedEvent $eventName$Event = EventManager.RegisterRoutedEvent(
            "$eventName$",
            RoutingStrategy.Bubble,
            typeof(RoutedEventHandler),
            typeof($className$));

        public event RoutedEventHandler $eventName$
        {
            add { AddHandler($eventName$Event, value); }
            remove { RemoveHandler($eventName$Event, value); }
        }

        /// <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">summary</span><span style="color:#0000ff;">&gt;</span>
        /// Invoke this method when you wish to raise a(n) $eventName$ event
        /// <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">summary</span><span style="color:#0000ff;">&gt;</span>
        private void Raise$eventName$Event()
        {
            RoutedEventArgs newEventArgs = new RoutedEventArgs($className$.$eventName$Event);
            RaiseEvent(newEventArgs);
        }

        #endregion]]<span style="color:#0000ff;">&gt;</span>
      <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Code</span><span style="color:#0000ff;">&gt;</span>
    <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Snippet</span><span style="color:#0000ff;">&gt;</span>
  <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">CodeSnippet</span><span style="color:#0000ff;">&gt;</span>
<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">CodeSnippets</span><span style="color:#0000ff;">&gt;</span></pre>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/56/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/56/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=56&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/06/13/code-snippet-for-wpf-routed-event/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>Windows Communication Foundation Introduction</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/05/01/windows-communication-foundation-introduction/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/05/01/windows-communication-foundation-introduction/#comments</comments>
		<pubDate>Thu, 01 May 2008 04:54:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/05/01/windows-communication-foundation-introduction/</guid>
		<description><![CDATA[Here’s a very (very!) quick WCF overview I prepared the other day for the team at Zap. It’s intended as a soldier’s five on the topic; no more and no less. Service Contracts and Operation Contracts This is what your WCF service promises faithfully to do for its callers. Data Contracts These are the data [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=10&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here’s a very (very!) quick WCF overview I prepared the other day for the team at Zap. It’s intended as a soldier’s five on the topic; no more and no less.</p>
<p><strong>Service Contracts and Operation Contracts</strong></p>
<p>This is what your WCF service promises faithfully to do for its callers.</p>
<p><a href="http://lh6.ggpht.com/_RlpLqbhdTdM/SSulbNwKMOI/AAAAAAAAZ8s/Zra9QhK6BvQ/s1600-h/image%5B4%5D.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" src="http://lh6.ggpht.com/_RlpLqbhdTdM/SSulcv2cZtI/AAAAAAAAZ80/q-o8PoOK6XE/image_thumb%5B2%5D.png?imgmax=800" border="0" alt="image" width="404" height="350" /></a></p>
<p><strong>Data Contracts</strong></p>
<p>These are the data types that your WCF service expects its callers to understand. Thankfully, it will happily explain these data types to its callers.</p>
<p><a href="http://lh4.ggpht.com/_RlpLqbhdTdM/SSuleHAgyHI/AAAAAAAAZ88/3x6u-x_Lh-I/s1600-h/clip_image002%5B4%5D.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image002" src="http://lh3.ggpht.com/_RlpLqbhdTdM/SSulfthFnUI/AAAAAAAAZ9E/Ap03SAa5xFE/clip_image002_thumb%5B1%5D.png?imgmax=800" border="0" alt="clip_image002" width="404" height="312" /></a></p>
<p><strong>Events (&#8230; or &#8220;Duplex Contracts&#8221;)</strong></p>
<p>Out of scope for this presentation, but see <a href="http://msdn.microsoft.com/en-us/library/ms731184.aspx">http://msdn.microsoft.com/en-us/library/ms731184.aspx</a> for a pretty decent explanation.</p>
<p><strong>Hosting Your WCF Service</strong></p>
<p><a href="http://lh5.ggpht.com/_RlpLqbhdTdM/SSulhEZNMDI/AAAAAAAAZ9M/gnJFpljlFqo/s1600-h/clip_image003%5B4%5D.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image003" src="http://lh4.ggpht.com/_RlpLqbhdTdM/SSulilE6DdI/AAAAAAAAZ9U/7alL9hwcuFo/clip_image003_thumb%5B1%5D.png?imgmax=800" border="0" alt="clip_image003" width="404" height="124" /></a></p>
<p>Note the endpoint address:</p>
<p><a href="http://lh6.ggpht.com/_RlpLqbhdTdM/SSulkaQ1jKI/AAAAAAAAZ9c/ObFgkzEroEM/s1600-h/clip_image004%5B4%5D.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image004" src="http://lh4.ggpht.com/_RlpLqbhdTdM/SSull2mZjTI/AAAAAAAAZ9k/H_7NPuWyb6Q/clip_image004_thumb%5B1%5D.png?imgmax=800" border="0" alt="clip_image004" width="404" height="257" /></a></p>
<p><strong>Adding a service reference to your project</strong></p>
<p>The metadata exchange address is the equivalent of the old Web Service Definition Language (WSDL) address.</p>
<p><a href="http://lh5.ggpht.com/_RlpLqbhdTdM/SSuln1sGsqI/AAAAAAAAZ9s/T9AkhVT-D-U/s1600-h/clip_image005%5B4%5D.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image005" src="http://lh4.ggpht.com/_RlpLqbhdTdM/SSulplHm8CI/AAAAAAAAZ90/jNq9dt5P9Ds/clip_image005_thumb%5B1%5D.png?imgmax=800" border="0" alt="clip_image005" width="404" height="329" /></a></p>
<p><strong>Calling the WCF Service</strong></p>
<p>Call it just as you would your local methods.</p>
<p><a href="http://lh4.ggpht.com/_RlpLqbhdTdM/SSulrMHss2I/AAAAAAAAZ98/I1IYrTYxocY/s1600-h/clip_image006%5B4%5D.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image006" src="http://lh6.ggpht.com/_RlpLqbhdTdM/SSultF9muuI/AAAAAAAAZ-E/5yAcOkUD6iU/clip_image006_thumb%5B1%5D.png?imgmax=800" border="0" alt="clip_image006" width="404" height="366" /></a></p>
<p>It&#8217;s that easy.</p>
<p>Purely for edification, this is what some of the generated code looks like:</p>
<p><a href="http://lh5.ggpht.com/_RlpLqbhdTdM/SSuluyOm4XI/AAAAAAAAZ-M/GeyLgNvMqJw/s1600-h/clip_image007%5B4%5D.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image007" src="http://lh5.ggpht.com/_RlpLqbhdTdM/SSulwQQYZAI/AAAAAAAAZ-U/RHh3wjYMP4g/clip_image007_thumb%5B1%5D.png?imgmax=800" border="0" alt="clip_image007" width="404" height="306" /></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=10&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/05/01/windows-communication-foundation-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/_RlpLqbhdTdM/SSulcv2cZtI/AAAAAAAAZ80/q-o8PoOK6XE/image_thumb%5B2%5D.png?imgmax=800" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://lh3.ggpht.com/_RlpLqbhdTdM/SSulfthFnUI/AAAAAAAAZ9E/Ap03SAa5xFE/clip_image002_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">clip_image002</media:title>
		</media:content>

		<media:content url="http://lh4.ggpht.com/_RlpLqbhdTdM/SSulilE6DdI/AAAAAAAAZ9U/7alL9hwcuFo/clip_image003_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">clip_image003</media:title>
		</media:content>

		<media:content url="http://lh4.ggpht.com/_RlpLqbhdTdM/SSull2mZjTI/AAAAAAAAZ9k/H_7NPuWyb6Q/clip_image004_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">clip_image004</media:title>
		</media:content>

		<media:content url="http://lh4.ggpht.com/_RlpLqbhdTdM/SSulplHm8CI/AAAAAAAAZ90/jNq9dt5P9Ds/clip_image005_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">clip_image005</media:title>
		</media:content>

		<media:content url="http://lh6.ggpht.com/_RlpLqbhdTdM/SSultF9muuI/AAAAAAAAZ-E/5yAcOkUD6iU/clip_image006_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">clip_image006</media:title>
		</media:content>

		<media:content url="http://lh5.ggpht.com/_RlpLqbhdTdM/SSulwQQYZAI/AAAAAAAAZ-U/RHh3wjYMP4g/clip_image007_thumb%5B1%5D.png?imgmax=800" medium="image">
			<media:title type="html">clip_image007</media:title>
		</media:content>
	</item>
		<item>
		<title>Common Assembly Attributes</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/03/25/common-assembly-attributes/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/03/25/common-assembly-attributes/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 06:49:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/03/25/common-assembly-attributes/</guid>
		<description><![CDATA[&#8230; or, &#8220;What&#8217;s that SolutionInfo.cs thingy for?&#8221; http://bloggingabout.net/blogs/jschreuder/archive/2006/11/02/Centralizing-AssemblyInfo-settings_2C00_-or-simplify-versioning-of-solutions.aspx<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=9&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8230; or, &#8220;What&#8217;s that SolutionInfo.cs thingy for?&#8221;</p>
<p><a href="http://bloggingabout.net/blogs/jschreuder/archive/2006/11/02/Centralizing-AssemblyInfo-settings_2C00_-or-simplify-versioning-of-solutions.aspx">http://bloggingabout.net/blogs/jschreuder/archive/2006/11/02/Centralizing-AssemblyInfo-settings_2C00_-or-simplify-versioning-of-solutions.aspx</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=9&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/03/25/common-assembly-attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>“The trust relationship between the primary domain and the trusted domain failed.”</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/03/25/%e2%80%9cthe-trust-relationship-between-the-primary-domain-and-the-trusted-domain-failed%e2%80%9d/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/03/25/%e2%80%9cthe-trust-relationship-between-the-primary-domain-and-the-trusted-domain-failed%e2%80%9d/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 06:46:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Providers]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/03/25/%e2%80%9cthe-trust-relationship-between-the-primary-domain-and-the-trusted-domain-failed%e2%80%9d/</guid>
		<description><![CDATA[This error will occur for many reasons. If you’ve arrived at this blog, however, the odds are that you’re searching for something .NET-related, possibly even a provider-related issue. A .NET provider specified in a web.config file has its status set to enabled=false by default. Don&#8217;t ask me why. This problem, when using a custom role [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=8&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This error will occur for many reasons. If you’ve arrived at this blog, however, the odds are that you’re searching for something .NET-related, possibly even a provider-related issue.</p>
<p>A .NET provider specified in a web.config file has its status set to enabled=false by default. Don&#8217;t ask me why.</p>
<p>This problem, when using a custom role provider, might manifest as the above error. Very frustrating, as none of the Google results I’ve seen will mention this particular cause of this error, anything about how to actually fix it.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=8&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/03/25/%e2%80%9cthe-trust-relationship-between-the-primary-domain-and-the-trusted-domain-failed%e2%80%9d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>Using DBML/LINQ to Generate WCF DataContracts</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/03/24/using-dbmllinq-code-as-wcf-datacontract-sources/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/03/24/using-dbmllinq-code-as-wcf-datacontract-sources/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 06:49:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/03/24/using-dbmllinq-code-as-wcf-datacontract-sources/</guid>
		<description><![CDATA[Yes, you can actually use the DBML editor to generate classes tagged with the WCF DataContract attribute. .NET 3.5 rocks. http://blogs.msdn.com/wriju/archive/2007/11/27/linq-to-sql-enabling-dbml-file-for-wcf.aspx<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=7&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yes, you can actually use the DBML editor to generate classes tagged with the WCF DataContract attribute.</p>
<p>.NET 3.5 rocks.</p>
<p><a href="http://blogs.msdn.com/wriju/archive/2007/11/27/linq-to-sql-enabling-dbml-file-for-wcf.aspx">http://blogs.msdn.com/wriju/archive/2007/11/27/linq-to-sql-enabling-dbml-file-for-wcf.aspx</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=7&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/03/24/using-dbmllinq-code-as-wcf-datacontract-sources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>WPF Context Menu Doesn’t Display on First Load</title>
		<link>http://codingforfunandprofit.wordpress.com/2008/02/14/wpf-context-menu-doesn%e2%80%99t-display-on-first-load/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2008/02/14/wpf-context-menu-doesn%e2%80%99t-display-on-first-load/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 06:52:00 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/2008/02/14/wpf-context-menu-doesn%e2%80%99t-display-on-first-load/</guid>
		<description><![CDATA[The problem: When using WPF OnContextMenuOpening, ContextMenu doesn&#8217;t display on first load. The reason: The OnContextMenuOpening routed event is used for dynamically creating a ContextMenu object for a particular UIElement. Each UIElement has a ContextMenu property which dictates what gets displayed when a user right-clicks on it. If the property is null, nothing will be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=6&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>The problem:</strong></p>
<p>When using WPF OnContextMenuOpening, ContextMenu doesn&#8217;t display on first load.</p>
<p><strong>The reason:</strong></p>
<p>The OnContextMenuOpening routed event is used for dynamically creating a ContextMenu object for a particular UIElement.</p>
<p>Each UIElement has a ContextMenu property which dictates what gets displayed when a user right-clicks on it. If the property is null, nothing will be displayed. If the property is not null, the context menu that it references will be displayed.</p>
<p>The catch? The ContextMenu property must not be null before the event handler first fires, or the menu won&#8217;t load. This appears to be a WPF bug, but it&#8217;s a pain either way.</p>
<p><strong>The solution:</strong></p>
<p>Create an empty ContextMenu object and assign it to each UIElement that&#8217;s going to have any context menu displayed. In the OnContextMenuOpening event, either Clear() the existing context menu or just create a new one and assign the property to the object reference. Either will work.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=6&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2008/02/14/wpf-context-menu-doesn%e2%80%99t-display-on-first-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>Enterasys2Orinoco</title>
		<link>http://codingforfunandprofit.wordpress.com/2003/03/18/enterasys2orinoco/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2003/03/18/enterasys2orinoco/#comments</comments>
		<pubDate>Mon, 17 Mar 2003 23:28:20 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/?p=51</guid>
		<description><![CDATA[The Melbourne Wireless group recently organised a few bulk purchases of Enterasys/Cabletron/Skynet Global 802.11b cards. In fact, these cards are simply re-badged Orinoco cards. This page will show you how to update the firmware in your Enterasys card to the most recent version of the Orinoco Silver firmware. Update: I just received mail from Matt [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=51&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://melbourne.wireless.org.au"></a>Melbourne Wireless group recently organised a few bulk purchases of Enterasys/Cabletron/Skynet Global 802.11b cards. In fact, these cards are simply re-badged Orinoco cards. This page will show you how to update the firmware in your Enterasys card to the most recent version of the Orinoco Silver firmware.</p>
<p>Update: I just received mail from Matt Johnston (thanks, Matt!) about a simpler way to flash the cards. I haven&#8217;t tested it personally, but if it works for you, it looks like it will be much quicker. Have a quick read <a href="#hexedit">here</a> and see what you think.</p>
<p>Update (18/3/03): Enterasys appear to be keeping reasonably up-to-date with their driver releases, so unless you&#8217;re looking to use the card under a non-supported OS or you want to flash your 40-bit WEP card to 128-bit, this is probably a bit too much trouble to go to <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Update (28/8/03): This page is no longer being updated. If you have queries about anything to do with your card&#8217;s configuration, please visit either the manufacturer&#8217;s web site or <a href="http://melbourne.wireless.org.au/" target="_blank">Melbourne Wireless</a>.</h3>
<h3>Frequently Asked Questions</h3>
<dl>
<dt><strong>Why would I want to do this?</strong> </p>
<ul>
<li>To fix broken Enterasys firmware that doesn&#8217;t properly support ad-hoc mode</li>
<li>To ensure inter-operability with other Lucent cards (not that this really seems to be a problem)</li>
<li>The possibility that you can then upgrade (using an Apple Airport) <em>this</em> firmware to Orinoco Gold, and thus get better encryption. (Try <a href="http://www.nextechwireless.net/support/silvertogoldwindows.html">this link)</a>.</li>
</ul>
</dt>
<dt><strong>Does it change the way my operating system identifies the card?</strong> </p>
<ul>
<li>No. Initial reports suggested that it did; after subsequent checking it appears that this is not the case. This is not to say that it cannot be done; simply that upgrading the firmware does not do it.</li>
</ul>
</dt>
<dt><strong>How can I make my Windows OS think the card is a true Lucent card?</strong> </p>
<ul>
<li>We don&#8217;t know. If you can work it out, please tell us. We have tried using PCI Set Register calls to change the card&#8217;s device ID; we have tried flashing them with all sorts of firmware. No change.</li>
<li>You <em>could</em> try seeing if there&#8217;s any other EEPROM on the cards themselves &#8211; and then writing your own flashing program to write a new image to it. Good luck <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
</dt>
<dt><strong>How can I make my Linux OS think the card is a true Lucent card?</strong> </p>
<ul>
<li>No need. It already uses the orinoco_cs driver anyway, so the card will perform exactly the same.</li>
</ul>
</dt>
<dt><strong>Which drivers should I use with the card after I update its firmware?</strong> </p>
<ul>
<li>The Enterasys ones.</li>
<li>They&#8217;ll still identify the card as a RoamAbout but its MAC functions will behave like a Lucent card.</li>
</ul>
</dt>
<dt><strong>So, why would I want to do this again?</strong> </p>
<ul>
<li>To fix ad-hoc mode.</li>
<li>Peace of mind that you&#8217;re running the latest (and presumably best) firmware that Lucent have released.</li>
</ul>
</dt>
</dl>
<h3>To re-flash your card, follow these steps:</h3>
<ol>
<li>Find a computer with a PCMCIA slot and a working installation of Windows 9x. 98SE is fine, as is Windows ME. Windows NT, 2000 and XP all appear <em>not</em> to work &#8211; there have been many reports of people struggling with it, and I haven&#8217;t heard of anyone doing it successfully.</li>
<li>Boot the machine without the card inserted.</li>
<li>Download an <em>old</em> version of the Orinoco drivers onto the machine and un-archive them into <em>C:\TEMP\ORINOCO-OLD</em>. You can <a href="files/wlw9870.exe">download the drivers from uglybugger.org here</a>. Do <em>not</em> use a more recent version of the drivers &#8211; they will refuse to detect the card. <strong>Do not install the drivers at this stage &#8211; simply unarchive them.</strong></li>
<li>Optional: Download the <em>current</em> version of the Orinoco drivers onto the machine get the most recent of these from <a href="http://www.orinocowireless.com/">www.orinocowireless.com</a>. Unarchive these into <em>C:\TEMP\ORINOCO-NEW</em>. <strong>Again, do <em>not</em> install these drivers &#8211; just unarchive them.</strong></li>
<li>Insert your Enterasys card into one of the machine&#8217;s PCMCIA slots. If your machine does not support hot-insertion of PCMCIA devices, reboot after this step.</li>
<li>When prompted for a driver for the card, click the <em>Have Disk</em> button and browse to <em>C:\TEMP\ORINOCO-OLD\DRIVER</em>.</li>
<li>Click <em>OK</em> and install the drivers for the card. You want the &#8220;5V Only&#8221; PCMCIA driver, <em>not</em> the 3.3/5V one.</li>
<li>Reboot the machine.</li>
<li>Run the program <a href="files/wsu10728.exe">C:\TEMP\ORINOCO-OLD\FIRMWARE\WSU10728.EXE</a></li>
<li>Click <em>Update</em> in the firmware update program, then <em>OK</em> to confirm.</li>
<li>Wait a few seconds <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>Close the program.</li>
<li>Your card will now identify itself as an Orinoco card (at least, according to the old driver), but it has an <em>old</em> firmware version and will probably not work correctly yet. Not to worry &#8211; that will soon be fixed.</li>
<li>Run the program <a href="files/wsu10810.exe">C:\TEMP\ORINOCO-NEW\FIRMWARE\WSU10810.EXE</a>. (If you didn&#8217;t download the new drivers, then just use the link given here.</li>
<li>Click <em>Update</em> in the new firmware update program, then <em>OK</em> to confirm.</li>
<li>Your card is now running the most recent Orinoco firmware. Be happy <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>If you have more than one card, remove the current one, replace it with another card to be updated, then repeat the last 9 steps.</li>
<li>Close the new firmware flashing program.</li>
<li>Now install the latest Enterasys drivers onto your machine. You can download these from their <a href="http://www.enterasys.com/">web site</a>.).</li>
</ol>
<p>Thanks to Will Lanigan and Danny (last name??) from Melbourne Wireless for the general information on how to do this.</p>
<p><a name="hexedit"></a></p>
<p><a name="hexedit"></a></p>
<pre>&gt; -----Original Message-----
&gt; From: Matt Johnston [mailto:matt [at] ucc [dot] gu [dot] uwa [dot] edu [dot] au]
&gt; Sent: Friday, 11 October 2002 12:38 AM
&gt; To: andrewh@uglybugger.org
&gt; Subject: Enterasys to Orinoco
&gt;
&gt;
&gt; Hi.
&gt;
&gt; I've used the instructions on your page for Enterasys -&gt;
&gt; Orinoco, and they've worked nicely. However I think I've
&gt; found a nicely simpler way to do it.
&gt;
&gt; Simply open the binary (the .exe) in a hexeditor (or capable
&gt; text editor such as vim), and replace "LUC" with "RBT". There
&gt; should only be one instance of it, it stands out.
&gt;
&gt; Now you can run the updater, and it'll happily work.
&gt;
&gt; I haven't done a huge lot of testing, but it appears to work.
&gt;
&gt; Cheers,
&gt; Matt</pre>
<p>Good luck <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/51/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/51/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=51&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2003/03/18/enterasys2orinoco/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
		<item>
		<title>Fetchmail Multidrop</title>
		<link>http://codingforfunandprofit.wordpress.com/2001/04/02/fetchmail-multidrop/</link>
		<comments>http://codingforfunandprofit.wordpress.com/2001/04/02/fetchmail-multidrop/#comments</comments>
		<pubDate>Sun, 01 Apr 2001 23:32:22 +0000</pubDate>
		<dc:creator>uglybugger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codingforfunandprofit.wordpress.com/?p=53</guid>
		<description><![CDATA[Disclaimer: This is an OLD, OLD blog post. I shudder to think how much this PERL code looks like it was written by a C programmer&#8230; If you still find it useful, great. If you&#8217;d like to mess with the code, great too. If you&#8217;re really annoyed with fetchmail and it doesn&#8217;t already have this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=53&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Disclaimer: This is an OLD, OLD blog post.</h2>
<h3>I shudder to think how much this PERL code looks like it was written by a C programmer&#8230;</h3>
<p>
	If you still find it useful, great. If you&#8217;d like to mess with the code, great too. If you&#8217;re really annoyed with fetchmail and it doesn&#8217;t already have this feature built in, why not change the fetchmail code yourself and submit it to the maintainers? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>	Why don&#8217;t I? Because I wanted to learn PERL&#8230;
</p>
<p>
	I recently had some trouble with fetchmail and multidrop mailboxes. fetchmail handles mail well when a local address is found in the To: field of an email, but badly when it has to extract address information from the other headers of an email. In particular, people on the BCC list of an email (and who never appear in &#8220;official&#8221; mail headers) are likely to never receive emails addressed to them when handled via fetchmail with a multidrop mailbox.
</p>
<p>
	I was also looking for an excuse to learn PERL (08/2004 update: wow, this page really <i>is</i> old&#8230;).
</p>
<p>
	<a href="http://www.qmail.org">qmail</a> has a nice solution where it inserts an <b>Delivered-To:</b> line into the mail headers. For virtual hosts, it prepends the domain name to the email account it was delivered to. My domain is uglybugger.org, so when the MX host for mail.uglybugger.org accepts mail for me, it dumps it into a single account. The headers it inserts look like this:
</p>
<pre>
Return-Path: Andrew.Harcourt@team.telstra.com
Delivered-To: uglybugger.org%uglybugger@uglybugger.org
Received: (cpmta 5066 invoked from network); 2 Apr 2001 21:59:52 -0700
Delivered-To: uglybugger.org%andrewh@uglybugger.org
Received: (cpmta 5062 invoked from network); 2 Apr 2001 21:59:51 -0700
</pre>
<p>
	Read this from the bottom up. You&#8217;ll see that the first <b>Delivered-To:</b> line reads <b>uglybugger.org%andrewh@uglybugger.org</b> and the second <b>Delivered-To:</b> line reads <b>uglybugger.org%uglybugger@uglybugger.org</b>.
</p>
<p>
	fetchmail can be configured to read <i>envelope addresses</i>. These are the addresses (such as the <b>Delivered-To:</b> line) that mail servers include in mail headers to record which <i>account</i> the mail was delivered to. This is an important distinction from which <i>address</i> the mail was intended for. You can tell fetchmail to use these headers by specifying the following in your .fetchmailrc file:
</p>
<pre>
envelope "Delivered-To:"
qvirtual "uglybugger.org%"
</pre>
<p>
	Obviously, please change the qvirtual line to read your domain <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
<p>
	The problem here is that fetchmail will only read headers top-down, and it matches the first one it finds. This breaks the <i>envelope</i>/<i>qvirtual</i> delivery process completely as fetchmail is unable to ignore the first line it receives. So if the <i>envelope</i>/<i>qvirtual</i> settings do not solve your problem, read on.
</p>
<p>
	What we need to do is specify an alternate delivery agent, so that we can handle our processing ourselves. You can do this by specifying an external Mail Delivery Agent for fetchmail. Use the <i>mda</i> keyword to point mail to a script that you can copy and paste from here:
</p>
<pre>
----- /usr/sbin/fetchmail-inject ----------
#!/usr/bin/perl
# fetchmail-inject
# Andrew Harcourt, 1 May, 2001
#
# this script removes a nasty header that fetchmail can't handle
# from incoming mail and then passes the mail to sendmail to
# deliver locally

# write the mail to a temp file on disk
# as we do, parse it for the address
# lines
local($outputName, $fromAddress, $toAddress, $cmd);

$outputName = "/tmp/message.".$$;
open(OUTFILE,"&gt; ".$outputName)
        || die "could not open $outputName!";

while (&amp;ltSTDIN&amp;gt) {
        if (/^Delivered-To: uglybugger\.org\%uglybugger\@uglybugger\.org/) {
                # just ignore this line - it's ugly
        }
        elsif (/^Delivered-To: uglybugger\.org\%(.*)\@uglybugger.org/) {
                $toAddress = $1."\@uglybugger.org";
        }
        elsif (/^From: .* /) {
                $fromAddress = $1;
        }
        elsif (/^From: /) {
                $fromAddress = $1;
        }
        elsif (/^From: .*/) {
                $fromAddress = $1
        }
        print OUTFILE $_;
}

close(OUTFILE);

# check that we have our addresses correct
if ($toAddress eq "") {
        $toAddress = "postmaster\@uglybugger.org";
}
if ($fromAddress eq "") {
        $fromAddress = "postmaster\@uglybugger.org";
}

# now call sendmail to deliver the message
$cmd = "/usr/sbin/sendmail -f $fromAddress $toAddress &lt; $outputName";
system($cmd);

-------------------------------------------
</pre>
<p>
	Good luck <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codingforfunandprofit.wordpress.com/53/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codingforfunandprofit.wordpress.com/53/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingforfunandprofit.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingforfunandprofit.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingforfunandprofit.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingforfunandprofit.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingforfunandprofit.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingforfunandprofit.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingforfunandprofit.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingforfunandprofit.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingforfunandprofit.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingforfunandprofit.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingforfunandprofit.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingforfunandprofit.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingforfunandprofit.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingforfunandprofit.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingforfunandprofit.wordpress.com&amp;blog=5647008&amp;post=53&amp;subd=codingforfunandprofit&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingforfunandprofit.wordpress.com/2001/04/02/fetchmail-multidrop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/26c73be81cda35268fb6f8aeb3f3664e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">uglybugger</media:title>
		</media:content>
	</item>
	</channel>
</rss>
