<?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:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>techencoder &#187; Programming</title>
	<atom:link href="http://techencoder.com/index.php/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://techencoder.com</link>
	<description>Technical ideas in a human readable format</description>
	<lastBuildDate>Tue, 31 Aug 2010 02:15:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>		<item>
		<title>GIS Q&amp;A</title>
		<link>http://techencoder.com/index.php/2010/07/gis-qa/</link>
		<comments>http://techencoder.com/index.php/2010/07/gis-qa/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 20:33:16 +0000</pubDate>
		<dc:creator>r.claypool</dc:creator>
				<category><![CDATA[GIS Links]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[StackOverflow]]></category>

		<guid isPermaLink="false">http://techencoder.com/?p=1215</guid>
		<description><![CDATA[GIS Stack Exchange started a private Beta today and opens to the public in one week. 8/1/2010 Update: Now open.]]></description>
			<content:encoded><![CDATA[<p><a href="http://gis.stackexchange.com"><img class="alignnone size-full wp-image-1216" title="gis-stack-exchange" src="http://techencoder.com/wp-content/uploads/2010/07/gis-stack-exchange.png" alt="GIS Stack Exchange" width="281" height="56" /></a></p>
<p><a href="http://gis.stackexchange.com">GIS Stack Exchange</a> started a private Beta today and opens to the public in one week.</p>
<p><em>8/1/2010 Update: Now open.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://techencoder.com/index.php/2010/07/gis-qa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Delete Multiple Builds in Hudson</title>
		<link>http://techencoder.com/index.php/2010/06/how-to-delete-multiple-builds-in-hudson/</link>
		<comments>http://techencoder.com/index.php/2010/06/how-to-delete-multiple-builds-in-hudson/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 04:35:40 +0000</pubDate>
		<dc:creator>r.claypool</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[quick tip]]></category>

		<guid isPermaLink="false">http://techencoder.com/?p=1201</guid>
		<description><![CDATA[Hudson is great for managing scheduled builds, but after a while the artifacts start to take up a considerable amount of space. Deleting them one by one is possible, but Hudson will do this for you: Note that this works retroactively. If you have 300 old builds and set the job to keep just 20, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://hudson-ci.org"><img class="alignnone size-full wp-image-1203" title="hudson-butler" src="http://techencoder.com/wp-content/uploads/2010/06/hudson-butler.png" alt="" width="96" height="96" /></a></p>
<p>Hudson <a href="http://stackoverflow.com/questions/616149/how-and-why-do-i-set-up-a-c-build-machine/616230#616230">is great</a> for managing scheduled builds, but after a while the artifacts start to take up a considerable amount of space.</p>
<p>Deleting them one by one is possible, but Hudson will do this for you:</p>
<p><img class="aligncenter size-full wp-image-1202" title="discard-old-builds" src="http://techencoder.com/wp-content/uploads/2010/06/discard-old-builds.png" alt="" width="562" height="147" /></p>
<p>Note that this works retroactively.  If you have 300 old builds and set the job to keep just 20, the next build will delete 281 builds.</p>
]]></content:encoded>
			<wfw:commentRss>http://techencoder.com/index.php/2010/06/how-to-delete-multiple-builds-in-hudson/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Mercurial (hg) into Adobe Flash Builder 4 (standalone installation)</title>
		<link>http://techencoder.com/index.php/2010/05/mecurial-and-flash-builder-4/</link>
		<comments>http://techencoder.com/index.php/2010/05/mecurial-and-flash-builder-4/#comments</comments>
		<pubDate>Wed, 05 May 2010 20:23:09 +0000</pubDate>
		<dc:creator>r.claypool</dc:creator>
				<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Eclipse Plug-ins]]></category>
		<category><![CDATA[Flash Builder 4]]></category>
		<category><![CDATA[Mercurial]]></category>

		<guid isPermaLink="false">http://techencoder.com/?p=1158</guid>
		<description><![CDATA[Flash Builder, Eclipse and Mercurial (Hg) are all new in my world, and I couldn&#8217;t find any instructions on getting them to play nicely together. If you are in the same boat, read on &#8230; These instructions are based on a stand alone installation of Flex Builder, but I suppose they are about the same [...]]]></description>
			<content:encoded><![CDATA[<p>Flash Builder, Eclipse and <a title="Mercurial Project Home" href="http://mercurial.selenic.com/">Mercurial (Hg)</a> are all new in my world, and I couldn&#8217;t find any instructions on getting them to play nicely together.  If you are in the same boat, read on &#8230;</p>
<h3><img class="aligncenter size-full wp-image-1160" title="FlashBuilder_and_Mercurial" src="http://techencoder.com/wp-content/uploads/2010/05/FlashBuilder_and_Mercurial.png" alt="" width="231" height="55" /><span id="more-1158"></span></h3>
<p><em>These instructions are based on a stand alone installation of Flex Builder, but I suppose they are about the same even if you are using the Flex Builder Eclipse plug-in.</em></p>
<ol>
<li>Click Help &gt; Install New Software &#8230;</li>
<p><img class="size-full wp-image-1165" title="FlexBuilder4_with_Hg_1" src="http://techencoder.com/wp-content/uploads/2010/05/FlexBuilder4_with_Hg_1.png" alt="" width="306" height="78" /></p>
<li>Click &#8216;Available Software Sites&#8217;</li>
<p><img class="size-full wp-image-1159" title="'Available Software Sites' Link" src="http://techencoder.com/wp-content/uploads/2010/05/FlexBuilder4_with_Hg_2.png" alt="" width="569" height="184" /></p>
<li>Click Add<img class="alignnone size-full wp-image-1167" title="'Add Avaiable Software' dialog" src="http://techencoder.com/wp-content/uploads/2010/05/FlexBuilder4_with_Hg_3.png" alt="" width="793" height="184" /></li>
<li>Enter a name and the url (<a title="Mercurial Eclipse Plug-in URL" href="http://hge.javaforge.com/hgeclipse">http://hge.javaforge.com/hgeclipse</a>), click OK</li>
<p><img class="alignnone size-full wp-image-1170" title="Add URL" src="http://techencoder.com/wp-content/uploads/2010/05/FlexBuilder4_with_Hg_4b.png" alt="" width="408" height="128" /></p>
<li>Click OK again to close the parent window and select &#8216;Mercurial Eclipse&#8217; in the &#8216;Work with&#8217; drop-down list.</li>
<p><img class="alignnone size-full wp-image-1169" title="FlexBuilder4_with_Hg_6" src="http://techencoder.com/wp-content/uploads/2010/05/FlexBuilder4_with_Hg_6.png" alt="Drop Down List Selection" width="601" height="218" /></p>
<li>Select HgEclipse and click Next, Next, Next, Finish</li>
<p><img class="alignnone size-full wp-image-1171" title="Selection" src="http://techencoder.com/wp-content/uploads/2010/05/FlexBuilder4_with_Hg_7.png" alt="" width="601" height="291" /></p>
<li>Now open a project.  Right click the project, select Team &gt; Share Project &#8230;</li>
<p><img class="alignnone size-full wp-image-1172" title="FlexBuilder4_with_Hg_13" src="http://techencoder.com/wp-content/uploads/2010/05/FlexBuilder4_with_Hg_13.png" alt="Team &gt; Share Project ..." width="412" height="295" /></p>
<li>Choose Mercurial (obviously) &#8230; click Next, Next, whatever, to finish the selections.</li>
<p><img class="alignnone size-full wp-image-1173" title="Repository Type Selection" src="http://techencoder.com/wp-content/uploads/2010/05/FlexBuilder4_with_Hg_14.png" alt="" width="389" height="214" /></p>
<li>Finished!  You should now see the Mercurial commands in the Team menu.</li>
<p><img class="alignnone size-full wp-image-1176" title="The Team menu using Mercurial" src="http://techencoder.com/wp-content/uploads/2010/05/FlexBuilder4_with_Hg_16.png" alt="" width="507" height="425" /></p>
<p>P.S.  Mercurial ROCKS !!!!  I&#8217;ve used VSS, Perforce, TFS and Subverion.  Subversion has always been my favorite, but Mercurial easily takes first place now.  The DVCS model is <a title="HG Init" href="http://hginit.com/">much better</a>.</ol>
]]></content:encoded>
			<wfw:commentRss>http://techencoder.com/index.php/2010/05/mecurial-and-flash-builder-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>401.x errors on IIS: Authentication Required</title>
		<link>http://techencoder.com/index.php/2010/03/iis-authentication-required/</link>
		<comments>http://techencoder.com/index.php/2010/03/iis-authentication-required/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 13:15:48 +0000</pubDate>
		<dc:creator>r.claypool</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[quick tip]]></category>

		<guid isPermaLink="false">http://techencoder.com/?p=1128</guid>
		<description><![CDATA[Quick Tip: Is your site suddenly requesting a user name and password? Most likely this is triggered by insufficient file system permissions. The error logs at %SYSTEMROOT%\System32\LogFiles\W3SVC###\*.log will narrow down your search and give the substatus and Win32 error codes for each HTTP 401. David Wang has a great write up about this on his [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://techencoder.com/wp-content/uploads/2010/03/iis-authentiction-required.png"><img class="aligncenter size-full wp-image-1129" title="iis-authentiction-required" src="http://techencoder.com/wp-content/uploads/2010/03/iis-authentiction-required-watermarked.png" alt="iis-authentiction-required" width="600" height="169" /></a></p>
<p><em>Quick Tip: <strong>Is your site suddenly requesting a user name and password?</strong></em></p>
<p>Most likely this is triggered by insufficient file system permissions.  The error logs at<br />
<code>%SYSTEMROOT%\System32\LogFiles\W3SVC###\*.log</code> will narrow down your search and give the <code>substatus</code> and <code>Win32</code><br />
error codes for each HTTP 401.  </p>
<p>David Wang has <a href="http://blogs.msdn.com/b/david.wang/archive/2005/07/14/howto-diagnose-iis-401-access-denied.aspx">a great write up</a> about this on his blog.  Check it out for more details.</p>
]]></content:encoded>
			<wfw:commentRss>http://techencoder.com/index.php/2010/03/iis-authentication-required/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-SQL: Cannot drop the index because it does not exist or you do not have permission.</title>
		<link>http://techencoder.com/index.php/2010/02/tsql-cannot-drop-theindex/</link>
		<comments>http://techencoder.com/index.php/2010/02/tsql-cannot-drop-theindex/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 12:20:43 +0000</pubDate>
		<dc:creator>r.claypool</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[quick tip]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://techencoder.com/?p=1085</guid>
		<description><![CDATA[Quick tip:&#160;&#160; The table name and index name are required to drop an index, otherwise SQL Server will return an error. e.g. DROP INDEX &#91;dbo&#93;.&#91;IX_MyIndex&#93; fails with &#8230; Msg 3701, Level 11, State 6, Line XX Cannot drop the index 'dbo.IX_MyIndex', because it does not exist or you do not have permission. However, DROP INDEX [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://techencoder.com/wp-content/uploads/2010/02/database.jpg"><img src="http://techencoder.com/wp-content/uploads/2010/02/database.jpg" alt="database" title="database" width="600" height="153" class="aligncenter size-full wp-image-1123" /></a></p>
<p><strong>Quick tip:</strong>&nbsp;&nbsp; The table name <em>and</em> index name are required to drop an index, otherwise SQL Server will return an error.</p>
<p>e.g.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">INDEX</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>IX_MyIndex<span style="color: #808080;">&#93;</span></pre></div></div>

<p> fails with &#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Msg 3701, Level 11, State 6, Line XX
Cannot drop the index 'dbo.IX_MyIndex', 
because it does not exist or you do not have permission.</pre></div></div>

<p>However,</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">INDEX</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>MyTable<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>IX_MyIndex<span style="color: #808080;">&#93;</span></pre></div></div>

<p> will work fine if it exists and you have sufficient permissions.   (Use <code>Select user_name()</code> to determine your user context, which will help to verify the permissions being used.)</p>
]]></content:encoded>
			<wfw:commentRss>http://techencoder.com/index.php/2010/02/tsql-cannot-drop-theindex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Intellisense for NAnt Build Files (VS 2005 and 2008)</title>
		<link>http://techencoder.com/index.php/2010/01/vs-intellisense-for-nant/</link>
		<comments>http://techencoder.com/index.php/2010/01/vs-intellisense-for-nant/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 05:05:06 +0000</pubDate>
		<dc:creator>r.claypool</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[NAnt]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://techencoder.com/?p=1050</guid>
		<description><![CDATA[Step 1. Make VS recognize a .build file as an XML file. Right-click a .build file in the &#8220;Solution Explorer&#8221; and select &#8220;Open With &#8230;&#8221; In the &#8220;Open With&#8221; dialog, select &#8220;XML Editor&#8221; and &#8220;Set as Default&#8221; Step 2: Enable intellisense for .build files. Get the schema file for NAnt: Version 0.86 Beta 1 is at [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://techencoder.com/wp-content/uploads/2010/01/nant.jpg" alt="nant" title="nant" width="600" height="106" class="aligncenter size-full wp-image-1100" /></p>
<h4>Step 1. Make VS recognize a .build file as an XML file.</h4>
<div>
<ol>
<li>Right-click a .build file in the &#8220;Solution Explorer&#8221; and select &#8220;Open With &#8230;&#8221;</li>
<li>In the &#8220;Open With&#8221; dialog, select &#8220;XML Editor&#8221; and &#8220;Set as Default&#8221;</li>
</ol>
<p><img class="aligncenter size-full wp-image-1053" title="vs-2005-2008-open-with-dialog" src="http://techencoder.com/wp-content/uploads/2010/01/vs-2005-2008-open-with-dialog.png" alt="vs-2005-2008-open-with-dialog" width="600" height="244" /></div>
<h4>Step 2: Enable intellisense for .build files.</h4>
<p>Get the schema file for NAnt:</p>
<ul>
<li>Version 0.86 Beta 1 is at <a title="XSD Schema for NAnt" href="http://nant.sf.net/release/0.86-beta1/nant.xsd" target="_blank">http://nant.sf.net/release/0.86-beta1/nant.xsd</a></li>
<li>Version 0.85 is at <a title="XSD Schema for NAnt" href="http://nant.sf.net/release/0.86-beta1/nant.xsd" target="_blank">http://nant.sf.net/release/0.85/nant.xsd</a></li>
</ul>
<p>Copy it to the &#8220;<em>xml\Schemas</em>&#8221; subdirectory of your VS installation:</p>
<div>
<ul>
<li>Note that you can check this path via <em>Tools &gt; Options &gt; Text Editor &gt; XML &gt; Miscellaneous</em></li>
</ul>
<p><img class="aligncenter size-full wp-image-1066" title="schema-location-option" src="http://techencoder.com/wp-content/uploads/2010/01/schema-location-option.png" alt="schema-location-option" width="600" height="347" /></div>
<div>Specify the schema to use within Visual Studio:</div>
<div>
<ul>
<li>Open the file so that it appears in a Visual Studio editor window.</li>
<li>Click the file&#8217;s editor window (to activate it) and specify the schema to use (within the &#8220;Properties&#8221; window).<br />
<img class="aligncenter size-full wp-image-1057" title="change-schema-properties" src="http://techencoder.com/wp-content/uploads/2010/01/change-schema-properties.png" alt="change-schema-properties" width="600" height="148" /></li>
</ul>
<ul>
<li>Note that this dialog has changed from VS 2005 to 2008:</li>
</ul>
<p style="text-align: center;"><img class="size-full wp-image-1058" title="xsd-schemas-vs-2005" src="http://techencoder.com/wp-content/uploads/2010/01/xsd-schemas-vs-2005.png" alt="Visual Studio 2005" width="600" height="231" /><br />
(VS 2005)</p>
<p><img class="size-full wp-image-1059" title="xsd-schemas-vs-2008" src="http://techencoder.com/wp-content/uploads/2010/01/xsd-schemas-vs-2008.png" alt="Visual Studio 2008" width="600" height="235" /><br />
(VS 2008)</p>
<p>If all of that is not enough,  make sure to <strong>enter an xmlns and make sure it is equal to the xmlns specified in the XSD schema</strong>. </p>
<p>
!!!!! Even though the schema is available at <a title="NANT XML Schema" href="http://nant.sourceforge.net/release/0.86-beta1/nant.xsd" target="_blank">http://nant.sf.net/release/0.86-beta1/nant.xsd</a> and <a title="NANT XML Schema" href="http://nant.sourceforge.net/release/0.86-beta1/nant.xsd" target="_blank">http://nant.sourceforge.net/release/0.86-beta1/nant.xsd</a>, you must reference the former url in your build file because it is the one referenced in nant.xsd. !!!!!</p>
<p>Here is an example of what I mean:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://nant.sf.net/release/0.86-beta1/nant.xsd&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;MyProject&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #808080; font-style: italic;">&lt;!-- stuff here --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Hope that helps someone.  Happy Programming!</p></div>
<hr/>
<div xmlns:cc="http://creativecommons.org/ns#" about="http://www.flickr.com/photos/kubina/521327318/">
Attribution: The <a href='http://www.flickr.com/photos/kubina/521327318/'>ant photo</a> in this post is used with permission (<a rel="license" href="http://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA 2.0</a>) by <a rel="cc:attributionURL" href="http://www.flickr.com/photos/kubina/">Jeff Kubina</a></div>
]]></content:encoded>
			<wfw:commentRss>http://techencoder.com/index.php/2010/01/vs-intellisense-for-nant/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting DataTables to work with ASP.Net MVC</title>
		<link>http://techencoder.com/index.php/2009/12/getting-datatables-to-work-with-asp-net-mvc/</link>
		<comments>http://techencoder.com/index.php/2009/12/getting-datatables-to-work-with-asp-net-mvc/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 07:13:12 +0000</pubDate>
		<dc:creator>r.claypool</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net MVC]]></category>
		<category><![CDATA[DataTables]]></category>

		<guid isPermaLink="false">http://techencoder.com/?p=1041</guid>
		<description><![CDATA[Want to get jQuery DataTables to work in an ASP.Net MVC project ??? Here is a demo project in C# that should get you started.  If I find the time, I&#8217;ll post details on how this was put together (but I think most developers will benefit more from running and stepping through the source code [...]]]></description>
			<content:encoded><![CDATA[<p>Want to get jQuery <a href="http://www.datatables.net/">DataTables</a> to work in an ASP.Net MVC project ???</p>
<p>Here is a <a href="http://techencoder.com/wp-content/uploads/2009/12/ASP.Net-MVC-and-DataTables-Demo.zip">demo project</a> in C# that should get you started.  If I find the time, I&#8217;ll post details on how this was put together (but I think most developers will benefit more from running and stepping through the source code anyway).</p>
<p>Hope this helps someone.  Happy Programming!</p>
]]></content:encoded>
			<wfw:commentRss>http://techencoder.com/index.php/2009/12/getting-datatables-to-work-with-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Viewing the Activity Log for VS 2010</title>
		<link>http://techencoder.com/index.php/2009/11/vs2010-activity-log/</link>
		<comments>http://techencoder.com/index.php/2009/11/vs2010-activity-log/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 20:41:07 +0000</pubDate>
		<dc:creator>r.claypool</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://techencoder.com/?p=918</guid>
		<description><![CDATA[Are you repeatedly getting a less than helpful error dialog in Visual Studio 2010? Go to the command line and run devenv.exe with logging, reproduce the error in the IDE and then open ActivityLog.xml: C:\&#62;cd &#34;C:\Program Files &#40;x86&#41;\Microsoft Visual Studio 10.0\Common7\IDE&#34; C:\Program Files &#40;x86&#41;\Microsoft Visual Studio 10.0\Common7\IDE&#62;devenv /Log C:\Program Files &#40;x86&#41;\Microsoft Visual Studio 10.0\Common7\IDE&#62;cd %APPDATA% [...]]]></description>
			<content:encoded><![CDATA[<p>Are you repeatedly getting a less than helpful error dialog in Visual Studio 2010?</p>
<p>Go to the command line and run <a title="devenv.exe logging" href="http://msdn.microsoft.com/en-us/library/ms241272(VS.100,lightweight).aspx">devenv.exe with logging</a>, reproduce the error in the IDE and then open ActivityLog.xml:</p>
<p><img class="aligncenter size-full wp-image-919" title="devenv" src="http://techencoder.com/wp-content/uploads/2009/10/devenv.png" alt="devenv" width="600" height="174" /></p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">C:\&gt;cd &quot;C:\Program Files <span style="color: #66cc66;">&#40;</span>x86<span style="color: #66cc66;">&#41;</span>\Microsoft Visual Studio <span style="color: #cc66cc;">10.0</span>\Common7\IDE&quot;
C:\Program Files <span style="color: #66cc66;">&#40;</span>x86<span style="color: #66cc66;">&#41;</span>\Microsoft Visual Studio <span style="color: #cc66cc;">10.0</span>\Common7\IDE&gt;devenv /Log
C:\Program Files <span style="color: #66cc66;">&#40;</span>x86<span style="color: #66cc66;">&#41;</span>\Microsoft Visual Studio <span style="color: #cc66cc;">10.0</span>\Common7\IDE&gt;cd <span style="color: #33cc33;">%</span><span style="color: #448888;">APPDATA</span><span style="color: #33cc33;">%</span>
C:\Documents and Settings\username\Application Data&gt;cd &quot;Microsoft\VisualStudio\<span style="color: #cc66cc;">10.0</span>&quot;
C:\Documents and Settings\username\Application Data\Microsoft\VisualStudio\<span style="color: #cc66cc;">10.0</span>&gt;dir ActivityLog.xml /B ActivityLog.xml
C:\Documents and Settings\username\Application Data\Microsoft\VisualStudio\<span style="color: #cc66cc;">10.0</span>&gt;notepad ActivityLog.xml</pre></div></div>

<p>Look for entries with type=Error, e.g.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;entry&gt;
&lt;record&gt;263&lt;/record&gt;
&lt;time&gt;2009/10/24 22:50:09.218&lt;/time&gt;
&lt;type&gt;Error&lt;/type&gt;
&lt;source&gt;Editor or Editor Extension&lt;/source&gt;
&lt;description&gt;System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.VisualStudio.Editor.Implementation.VsFontsAndColorsInformation.GetEditorFontForItem(IVsColorTable colorTable, Int32 itemIndex, FONTCOLORPREFERENCES2 fontColorPreferences)
at Microsoft.VisualStudio.Editor.Implementation.VsFontsAndColorsInformation.TryGetItemValue(String itemKey, ResourceDictionary&amp; itemValue)
at Microsoft.VisualStudio.Text.Classification.Implementation.EditorFormatMap.CreateResourceDictionaryFromProvision(String key)
at Microsoft.VisualStudio.Text.Classification.Implementation.EditorFormatMap.GetProperties(String key)
at Microsoft.VisualStudio.Text.Classification.Implementation.ClassificationFormatMap.GetDefaultProperties()
at Microsoft.VisualStudio.Text.Classification.Implementation.ClassificationFormatMap..ctor(ICollection`1 formats, IClassificationTypeRegistryService classificationTypeRegistry, IEditorFormatMap formatMap)
at Microsoft.VisualStudio.Text.Classification.Implementation.ClassificationFormatMapService.GetClassificationFormatMap(String category)
at Microsoft.VisualStudio.Text.Classification.Implementation.ViewSpecificFormatMap.AttachToFormatMaps()
at Microsoft.VisualStudio.Text.Classification.Implementation.ViewSpecificFormatMap..ctor(IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, ITextView textView)
at Microsoft.VisualStudio.Text.Classification.Implementation.EditorFormatMapService.&lt;&gt;c__DisplayClass1.&lt;GetEditorFormatMap&gt;b__0()
at Microsoft.VisualStudio.Utilities.PropertyCollection.GetOrCreateSingletonProperty[T](Object key, Func`1 creator)
at Microsoft.VisualStudio.Text.Classification.Implementation.EditorFormatMapService.GetEditorFormatMap(ITextView textView)
at Microsoft.VisualStudio.Text.Editor.Implementation.OutliningAdornmentManagerFactory.CreateTagger[T](ITextView textView, ITextBuffer buffer)
at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)&lt;/description&gt;
&lt;/entry&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://techencoder.com/index.php/2009/11/vs2010-activity-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Castle Windsor 2.0 in ASP.Net MVC 1.0</title>
		<link>http://techencoder.com/index.php/2009/10/castle-windsor-and-aspnet-mvc/</link>
		<comments>http://techencoder.com/index.php/2009/10/castle-windsor-and-aspnet-mvc/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 05:26:33 +0000</pubDate>
		<dc:creator>r.claypool</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.Net MVC]]></category>
		<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[IoC]]></category>
		<category><![CDATA[Windsor]]></category>

		<guid isPermaLink="false">http://techencoder.com/?p=670</guid>
		<description><![CDATA[Consider yourself warned:  I&#8217;m just getting started with ASP.Net MVC, Dependency Injection (DI) and Inversion of Control (IoC), so this post is more for my benefit than yours. ASP.Net MVC 1.0 ASP.Net MVC 1.0 was released in March 2009. Read this tutorial to start learning it. Note that ASP.Net MVC is bin deployable which is [...]]]></description>
			<content:encoded><![CDATA[<p>Consider yourself warned:  I&#8217;m just getting started with ASP.Net MVC, Dependency Injection (DI) and Inversion of Control (IoC), so this post is <a title="Why blog? The best way to learn something is to teach it." href="http://stackoverflow.com/questions/745570/how-can-social-networking-sites-make-you-a-better-developer/745703#745703">more for my benefit than yours</a>.</p>
<p><img class="aligncenter size-full wp-image-698" title="warning-castle-windsor" src="http://techencoder.com/wp-content/uploads/2009/06/warning-castle-windsor.jpg" alt="warning-castle-windsor" width="600" height="158" /></p>
<h3>ASP.Net MVC 1.0</h3>
<p><a title="Download ASP.Net MVC" href="http://msdn.microsoft.com/en-us/library/dd394709.aspx">ASP.Net MVC 1.0</a> was released in March 2009. Read <a title="ASP.Net MVC Tutorial" href="http://weblogs.asp.net/scottgu/archive/2009/04/28/free-asp-net-mvc-nerddinner-tutorial-now-in-html.aspx">this tutorial</a> to start learning it. Note that ASP.Net MVC is <a title="bin deploy ASP.Net MVC" href="http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx">bin deployable</a> which is very nice if you don&#8217;t want to install anything on the production web server.</p>
<h3>Inversion of Control and Castle Windsor</h3>
<p>Castle Windsor 2.0 was just released this Summer after <a title="Castle Windsor 2.0 RTM Released" href="http://ayende.com/Blog/archive/2009/05/05/castle-windsor-2.0-rtm-released.aspx">a very long development period</a>.  To start using it, <a href="http://www.castleproject.org/castle/download.html">go get the dlls</a> and reference them in your project.</p>
<p>If you are completely new to the IoC pattern, go <a href="http://msdn.microsoft.com/en-us/magazine/cc337885.aspx">read James Kovacs&#8217; article</a> and <a title="DimeCasts: Castle Windsor series" href="http://www.dimecasts.net/Casts/ByTag/Windsor%20Castle">watch these videos</a>.  They will get a typical .Net programmer up to speed pretty fast.  You should also go to <a href="http://martinfowler.com/articles/injection.html">the canonical source for IoC</a>, but frankly I learned more from the other links and I think you will too.</p>
<p>To learn how to configure the Windsor container in your project, <a title="Castle Windsor Documentation" href="http://www.castleproject.org/container/documentation/trunk/index.html">read the project&#8217;s documentation</a> and continue with this article for an example in ASP.Net MVC.</p>
<h3>Putting them Together</h3>
<p><img class="aligncenter size-full wp-image-696" title="castle-plus-aspnet-mvc" src="http://techencoder.com/wp-content/uploads/2009/06/castle-plus-aspnet-mvc.png" alt="castle-plus-aspnet-mvc" width="600" height="64" /></p>
<p>Getting Windsor to work in an ASP.Net MVC application is easy if you know what to do.  Most things are that way, huh?</p>
<p>For a bare bones integration, just follow these steps:</p>
<ol>
<li>Install ASP.NET MVC 1.0.  The <a title="Microsoft Web Platform Installer" href="http://www.microsoft.com/web/Downloads/platform.aspx">Web Platform Installer</a> is great for this and a ton of other projects.  Try it.  You&#8217;ll be glad you did.</li>
<li>Open VS 2008,  go to File-&gt;New-&gt;Project&#8230; and select the &#8220;<em>ASP.NET MVC Web Application</em>&#8221; project template.</li>
<li>Select &#8220;No&#8221; on the proceeding dialog.  Do not create a unit test project.</li>
<li><a title="Castle Windsor download page" href="http://www.castleproject.org/castle/download.html">Download</a> Castle Windsor 2.0</li>
<li>Copy the dlls (<em>Castle.DynamicProxy2, Castle.MicroKernel, Castle.Windsor and Castle.Core</em>) to your solution&#8217;s folder or a sub folder.</li>
<li>Add them as references to the web project. (Right-click the &#8220;References&#8221; folder, select &#8220;Add Reference&#8230;&#8221;, select the &#8220;Browse&#8221; tab and navigate to the dlls to add them.)</li>
<li>Add a new XML file to the web project.  Name it &#8220;windsor.config&#8221; and enter the following:</li>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--Note: Since this is a web application, all components must have a lifesytle of 'transient' or 'preWebRequest' --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;components<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #808080; font-style: italic;">&lt;!--This is where we could declaratively add components to the Windsor container if we wanted to.--&gt;</span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/components<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<li>Create an interface IMessageHolder and a class MessageHolder.  (We will use this code to illustrate injecting an instance of MessageHolder into the HomeController.)</li>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">interface</span> IMessageHolder
<span style="color: #000000;">&#123;</span>
	<span style="color: #FF0000;">string</span> GetMessage<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> MessageHolder <span style="color: #008000;">:</span> IMessageHolder
<span style="color: #000000;">&#123;</span>
	<span style="color: #008080;">#region IMessageHolder Members</span>
&nbsp;
	<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> GetMessage<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0600FF;">return</span> <span style="color: #666666;">&quot;Welcome to ASP.NET MVC using Castle Windsor 2.0!&quot;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #008080;">#endregion</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<li>Create a controller factory for Windsor:</li>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> WindsorControllerFactory <span style="color: #008000;">:</span> DefaultControllerFactory
<span style="color: #000000;">&#123;</span>
	<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> IWindsorContainer _container<span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #0600FF;">public</span> WindsorControllerFactory<span style="color: #000000;">&#40;</span>IWindsorContainer container<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		_container <span style="color: #008000;">=</span> container<span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> IController GetControllerInstance<span style="color: #000000;">&#40;</span>Type controllerType<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>controllerType <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #008080; font-style: italic;">// Force an exception message from the base class.</span>
			<span style="color: #008080; font-style: italic;">// This will be more informative than what we would get otherwise,</span>
			<span style="color: #008080; font-style: italic;">// see: http://stackoverflow.com/questions/719678/custom-controller-factory-dependency-injection-structuremap-problems-with-asp/721313#721313</span>
			<span style="color: #0600FF;">return</span> <span style="color: #0600FF;">base</span>.<span style="color: #0000FF;">GetControllerInstance</span><span style="color: #000000;">&#40;</span>controllerType<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #008080; font-style: italic;">// Exception here ????</span>
		<span style="color: #008080; font-style: italic;">// Check the windsor configuration.</span>
		<span style="color: #008080; font-style: italic;">// Make sure that Windsor can match the component to load.</span>
		<span style="color: #0600FF;">return</span> _container.<span style="color: #0000FF;">Resolve</span><span style="color: #000000;">&#40;</span>controllerType<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">as</span> IController<span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> ReleaseController<span style="color: #000000;">&#40;</span>IController controller<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		_container.<span style="color: #0000FF;">Release</span><span style="color: #000000;">&#40;</span>controller<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<li>Open Global.asax.cs and replace it with the following:</li>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> MvcApplication <span style="color: #008000;">:</span> HttpApplication
<span style="color: #000000;">&#123;</span>
	<span style="color: #008080; font-style: italic;">/// &lt;remarks&gt;</span>
	<span style="color: #008080; font-style: italic;">/// This has to be static, because more than one instance</span>
	<span style="color: #008080; font-style: italic;">/// of the HttpApplication can potentially be created.</span>
	<span style="color: #008080; font-style: italic;">/// &lt;/remarks&gt;</span>
	<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> IWindsorContainer _container<span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> RegisterRoutes<span style="color: #000000;">&#40;</span>RouteCollection routes<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		routes.<span style="color: #0000FF;">IgnoreRoute</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;{resource}.axd/{*pathInfo}&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
		routes.<span style="color: #0000FF;">MapRoute</span><span style="color: #000000;">&#40;</span>
			<span style="color: #666666;">&quot;Default&quot;</span>, <span style="color: #008080; font-style: italic;">// Route name</span>
			<span style="color: #666666;">&quot;{controller}/{action}/{id}&quot;</span>, <span style="color: #008080; font-style: italic;">// URL with parameters</span>
			<span style="color: #008000;">new</span> <span style="color: #000000;">&#123;</span>controller <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Home&quot;</span>, action <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Index&quot;</span>, id <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #000000;">&#125;</span> <span style="color: #008080; font-style: italic;">// Parameter defaults</span>
			<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Application_Start<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		RegisterRoutes<span style="color: #000000;">&#40;</span>RouteTable.<span style="color: #0000FF;">Routes</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
		InitializeWindsor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
		<span style="color: #008080; font-style: italic;">// Setup the MVC framework to use our Windsor controller factory.</span>
		ControllerBuilder.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">SetControllerFactory</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> WindsorControllerFactory<span style="color: #000000;">&#40;</span>_container<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">virtual</span> <span style="color: #0600FF;">void</span> InitializeWindsor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>_container <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			_container <span style="color: #008000;">=</span> Build<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;windsor.config&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> IWindsorContainer Build<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> configPath<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		var resource <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> FileResource<span style="color: #000000;">&#40;</span>configPath<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
		var interperter <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XmlInterpreter<span style="color: #000000;">&#40;</span>resource<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
		var container <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WindsorContainer<span style="color: #000000;">&#40;</span>interperter<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
		<span style="color: #008080; font-style: italic;">// Register controllers</span>
		container.<span style="color: #0000FF;">Register</span><span style="color: #000000;">&#40;</span>AllTypes
					   .<span style="color: #0000FF;">Of</span><span style="color: #008000;">&lt;</span>Controller<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
					   .<span style="color: #0000FF;">FromAssembly</span><span style="color: #000000;">&#40;</span>Assembly.<span style="color: #0000FF;">GetExecutingAssembly</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #008080; font-style: italic;">/* Modify the name with which the component is registered
		See: http://blog.andreloker.de/post/2009/03/28/ASPNET-MVC-with-Windsor-programmatic-controller-registration.aspx */</span>
					   .<span style="color: #0000FF;">Configure</span><span style="color: #000000;">&#40;</span>c <span style="color: #008000;">=&gt;</span> c.<span style="color: #0000FF;">LifeStyle</span>.<span style="color: #0000FF;">Transient</span>.<span style="color: #0000FF;">Named</span><span style="color: #000000;">&#40;</span>c.<span style="color: #0000FF;">Implementation</span>.<span style="color: #0000FF;">Name</span>.<span style="color: #0000FF;">ToLower</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
		<span style="color: #008080; font-style: italic;">// Register all other types.</span>
		container.<span style="color: #0000FF;">Register</span><span style="color: #000000;">&#40;</span>
			Component.<span style="color: #0600FF;">For</span><span style="color: #008000;">&lt;</span>IMessageHolder<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">ImplementedBy</span><span style="color: #008000;">&lt;</span>MessageHolder<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">LifeStyle</span>.<span style="color: #0000FF;">Transient</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
		<span style="color: #0600FF;">return</span> container<span style="color: #008000;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<li>Add a constructor to the HomeController and give it an IMessageHolder parameter.</li>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #000000;">&#91;</span>HandleError<span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> HomeController <span style="color: #008000;">:</span> Controller
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> IMessageHolder _holder<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> HomeController<span style="color: #000000;">&#40;</span>IMessageHolder holder<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            _holder <span style="color: #008000;">=</span> holder<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> ActionResult Index<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            ViewData<span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;Message&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> _holder.<span style="color: #0000FF;">GetMessage</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">return</span> View<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> ActionResult About<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> View<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre></div></div>

<p>
Since IMessageHolder is registered with Windsor, the container will resolve IMessageHolder to an instance of MessageHolder at run-time.  This is called <a href="http://en.wikipedia.org/wiki/Dependency_injection">dependency injection</a> because the HomeController dependency is injected through the constructor.  Of course, you could do this without an IoC container such as Windsor, but in larger (real world) applications the container will greatly simplify the process of managing dependencies, which means you have a better chance of keeping things <a href="http://en.wikipedia.org/wiki/Loose_coupling">loosely coupled</a> and falling into <a href="http://www.codinghorror.com/blog/archives/000940.html">the pit of success</a>.
</p>
<p>
Notice also that we display the message in Index() to verify that the Windsor container is giving us a valid instance of the type registered for IMessageHolder.  This is just a simple way to see the result of what occurred.
</p>
<li>Run the application and you should see the message on the home page.  Click <a href='http://techencoder.com/wp-content/uploads/2009/10/mvcwebapplication1.zip'>here</a> to download the sample project.</li>
<p><img src="http://techencoder.com/wp-content/uploads/2009/10/aspnet-and-windsor-integration.png" alt="aspnet-and-windsor-integration" title="aspnet-and-windsor-integration" width="600" height="404" class="aligncenter size-full wp-image-956" />
</ol>
<p>
<a href='http://techencoder.com/wp-content/uploads/2009/10/mvcwebapplication1.zip'>Project Source Code</a> for this post.
</p>
<p>I hope that this walk-through helps someone get started with Windsor.  It really is an incredible project to learn and if used correctly it will make your programs much better.  Have fun with it and Happy Programming!</p>
]]></content:encoded>
			<wfw:commentRss>http://techencoder.com/index.php/2009/10/castle-windsor-and-aspnet-mvc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Batch file error: ∩╗┐is not recognized</title>
		<link>http://techencoder.com/index.php/2009/10/batch-file-formatting/</link>
		<comments>http://techencoder.com/index.php/2009/10/batch-file-formatting/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 13:15:47 +0000</pubDate>
		<dc:creator>r.claypool</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ANSI]]></category>
		<category><![CDATA[Batch Files]]></category>
		<category><![CDATA[quick tip]]></category>
		<category><![CDATA[UTF-8]]></category>

		<guid isPermaLink="false">http://techencoder.com/?p=903</guid>
		<description><![CDATA[Is your batch file reporting an error like this? Open the file in Notepad++, select &#8216;Format -&#62; Encode in ANSI&#8217; and save. Hope that helps someone.  Happy Programming!]]></description>
			<content:encoded><![CDATA[<p>Is your batch file reporting an error like this?</p>
<div id="attachment_905" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-905" title="cmd-prompt-error" src="http://techencoder.com/wp-content/uploads/2009/10/cmd-prompt-error.png" alt="'n++ECHO' is not recognized as an internal or external command, operable program or batch file." width="600" height="180" /><p class="wp-caption-text">&#39;n++ECHO&#39; is not recognized as an internal or external command, operable program or batch file.</p></div>
<p>Open the file in <a title="Notepad ++ Home Page" href="http://notepad-plus.sourceforge.net/uk/site.htm">Notepad++</a>, select &#8216;Format -&gt; Encode in ANSI&#8217; and save.</p>
<p><img class="aligncenter size-full wp-image-910" title="encode-file-in-ansi" src="http://techencoder.com/wp-content/uploads/2009/10/encode-file-in-ansi.png" alt="encode-file-in-ansi" width="600" height="300" /></p>
<p>Hope that helps someone.  Happy Programming!</p>
]]></content:encoded>
			<wfw:commentRss>http://techencoder.com/index.php/2009/10/batch-file-formatting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
