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

<channel>
	<title>Purposeful Procrastination &#187; .NET</title>
	<atom:link href="http://jtnlex.com/blog/category/programming/dotnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://jtnlex.com/blog</link>
	<description>It'll be useful someday, surely.</description>
	<lastBuildDate>Fri, 15 Jul 2011 04:19:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Google Closure Compiler in .NET via IKVM</title>
		<link>http://jtnlex.com/blog/2011/07/15/google-closure-compiler-in-net-via-ikvm/</link>
		<comments>http://jtnlex.com/blog/2011/07/15/google-closure-compiler-in-net-via-ikvm/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 04:17:33 +0000</pubDate>
		<dc:creator>JT</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[ikvm]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming tips]]></category>

		<guid isPermaLink="false">http://jtnlex.com/blog/?p=146</guid>
		<description><![CDATA[The Google Closure Compiler is a great tool for minifying JavaScript &#8211; it has the ability to both minify and optimize code, with output that&#8217;s both lightweight and performant. If you&#8217;re living on the .NET stack though, the fact that it&#8217;s in Java might be an impediment to either use or integration. In this post [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://code.google.com/closure/compiler/">Google Closure Compiler</a> is a great tool for minifying JavaScript &#8211; it has the ability to both minify and optimize code, with output that&#8217;s both lightweight and performant. If you&#8217;re living on the .NET stack though, the fact that it&#8217;s in Java might be an impediment to either use or integration.</p>
<p>In this post I&#8217;m going to go through the basics of using <a href="http://www.ikvm.net/">IKVM</a> to cross-compile the Java libraries to .NET and allow the closure compiler to run on the .NET platform.</p>
<p>If you haven&#8217;t come across IKVM before, the short description is that it&#8217;s a platform bridge for Java to .NET. It translates Java byte code to MSIL, and provides a .NET compiled version of the OpenJDK runtime. You can find out more on the website &#8211; in short, it&#8217;s amazing.</p>
<p>There are <a href="http://sourceforge.net/apps/mediawiki/ikvm/index.php?title=User%27s_Guide#Overview">two ways to roll with this</a>. IKVM supports a both dynamic mode, where jars or classes are cross-compiled at runtime; and a static mode, where a compiler produces a DLL or EXE from the jars or classes. In the static case, the resulting DLL can then be used from other .NET code to integrate Java APIs into .NET applications.</p>
<h3>Getting started</h3>
<p>First thing&#8217;s first: <a href="http://www.ikvm.net/download.html">download IKVM</a> and the <a href="http://code.google.com/p/closure-compiler/">closure compiler jar</a>. You will also need the <a href="http://code.google.com/p/closure-compiler/source/browse/trunk/lib/json.jar"><code>json.jar</code> library</a> that can be found in the <a href="http://code.google.com/p/closure-compiler/source/browse/trunk/lib/">closure compiler source</a>. (Note that none of the following requires a JRE or JDK for this to work &#8211; just the .NET runtime, version 2 and above.)</p>
<p>Extract IKVM and the closure compiler to separate folders on your disk, placing the <code>json.jar</code> file in the same folder as <code>compiler.jar</code>.</p>
<h3>Running in dynamic mode</h3>
<p>This is the simplest method of execution, as the ikvm executable works the same way that the JRE does. Open a command line in the folder where the closure compiler jar resides and execute:</p>
<pre class="brush:plain">
[path-to-ikvm]\bin\ikvm -jar compiler.jar --js=[source-javascript] --js_output_file=[destination-javascript-file]
</pre>
<p>This will run the compiler and output the result to the specified location.</p>
<p>While this mode is simple, you will have noticed that it&#8217;s slow to run &#8211; it took about 15s on my system compared with less than 5s using the JRE. This penalty comes from the fact that IKVM needs to cross-compile the jar before it runs &#8211; let&#8217;s speed it up.</p>
<h3>Static compilation</h3>
<p>For this section, we&#8217;ll compile the compiler.jar to compiler.exe &#8211; a Windows executable that runs on the .NET runtime.</p>
<p>From the command line, execute the following:</p>
<pre class="brush:plain">
[path to ikvm]\bin\<strong>ikvmc</strong> -out:compiler.exe json.jar compiler.jar
</pre>
<p>Note that we&#8217;re using <strong>ikvmc</strong> (the compiler) here, not <strong>ikvm</strong> (the runtime). The above command instructs the IKVM compiler to compile the two jars into a single executable, and put the result into compiler.exe.</p>
<p>Why <code>json.jar</code>? Good question. This jar is a static dependency of the closure compiler, though I&#8217;m not sure where it&#8217;s  used (by the closure compiler). Adding it to the command line in this way means that it is compiled into the same executable as as the closure compiler, making the resulting executable easier to handle.  It is possible to compile the <code>json.jar</code> separately, then reference the resulting DLL when compiling <code>closure.jar</code>:</p>
<pre class="brush:plain">
[path to ikvm]\bin\ikvmc -out:json.dll json.jar
[path to ikvm]\bin\ikvmc -out:compiler.exe -reference:json.dll compiler.jar
</pre>
<p>Not rocket science &#8211; you&#8217;ll notice the <code>json.dll</code> is also output in the current folder, and that the <code>compiler.exe</code> decreases in size.</p>
<p>Now if you&#8217;ve executed the above commands, you will have noticed that a number of warnings are output by the compiler, for example:</p>
<pre class="brush:plain">
Warning IKVMC0100: class "org.apache.xmlbeans.XmlCursor$TokenType" not found
Warning IKVMC0100: class "org.apache.xmlbeans.XmlCursor" not found
Warning IKVMC0111: emitted java.lang.NoClassDefFoundError in "com.google.javascript.jscomp.mozilla.rhino.xml.impl.xmlbeans.LogicalEquality.nodesEqual(Lorg.apache.xmlbeans.XmlCursor;Lorg.apache.xmlbeans.XmlCursor;)Z"    ("org.apache.xmlbeans.XmlCursor")
</pre>
<p>What you&#8217;re being warned about here is an unresolved dependency in the <code>compiler.jar</code>. The Rhino JavaScript interpreter, which is included by the closure compiler has a dependency on the <a href="http://xmlbeans.apache.org/">Apache XML Beans project</a>. This isn&#8217;t used by the closure compiler AFAIK, so it can be ignored. You could, however, get the XML beans project and start compiling that (and all its dependencies) but in this case it&#8217;s not worth it. The same goes for the ANT dependency that is also shown in the warnings. The closure compiler doesn&#8217;t use these bits so you can ignore it.</p>
<h3>Running compiler.exe</h3>
<p>Now you have the executable, but when it runs it will crash &#8211; why? Merely that the executable needs some IKVM DLLs present to find the core library parts. These are all present in the IKVM bin folder. The selection of these that we need is:</p>
<ul>
<li>IKVM.OpenJDK.Core.dll</li>
<li>IKVM.OpenJDK.SwingAWT.dll</li>
<li>IKVM.OpenJDK.Text.dll</li>
<li>IKVM.OpenJDK.Util.dll</li>
<li>IKVM.OpenJDK.XML.API.dll</li>
<li>IKVM.Runtime.dll</li>
</ul>
<p>The dependency list can be found by inspecting the executable for its library references, saving you from needing to copy the entire set of IKVM library DLLs.</p>
<p>Copy the above list from the IKVM bin folder to be alongside compiler.exe. You can now run &#8220;<code>compiler -?</code>&#8221; without issue. </p>
<p>Of course, compiling JavaScript is also on the cards:</p>
<pre class="brush:plain">
compiler --js=[source-javascript] --js_output_file=[destination-javascript-file]
</pre>
<p>There&#8217;s no explicit use of  IKVM here &#8211; all that&#8217;s used are the runtime DLLs. If you look at the decompiled version of the code you&#8217;ll see that there&#8217;s very little extra weight added by IKVM, and some of that (the line number symbols) is optional.</p>
<h3>Speed</h3>
<p>Running a test on the JQuery source code on my machines resulted in the following results.</p>
<table>
<tr>
<td>JRE</td>
<td>7s</td>
</tr>
<tr>
<td>IKVM</td>
<td>16s</td>
</tr>
<tr>
<td>Compiled</td>
<td>8s</td>
</tr>
</table>
<p>As you can see, while the runtime compilation option is expensive, the compiled .NET code runs at a comparable speed to its &#8216;native&#8217; JRE counterpart. <a href="https://twitter.com/JeroenFrijters">Jeroen Frijters</a> has done an amazing job to get IKVM performing as it does.</p>
<p>This is just the start of what is possible &#8211; the real reason I wanted to look at the Closure Compiler is to see about integrating it with the <a href="http://clientdependency.codeplex.com/">Client Dependency Framework</a> &#8211; a filter that enables minification and bundling via an ASP.NET handler. More on that to come&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://jtnlex.com/blog/2011/07/15/google-closure-compiler-in-net-via-ikvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use build configurations to control Razor compilation</title>
		<link>http://jtnlex.com/blog/2011/05/20/use-build-configurations-to-control-razor-compilation/</link>
		<comments>http://jtnlex.com/blog/2011/05/20/use-build-configurations-to-control-razor-compilation/#comments</comments>
		<pubDate>Fri, 20 May 2011 00:27:02 +0000</pubDate>
		<dc:creator>JT</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming tips]]></category>

		<guid isPermaLink="false">http://jtnlex.com/blog/?p=136</guid>
		<description><![CDATA[Recently Phil Haack posted an article on &#8220;Compiling MVC Views In A Build Environment&#8221;, describing how to switch on view compilation. This can be incredibly useful, surfacing compilation errors across the project rather than relying on picking it up at runtime. However, I found that it slows compilation down quite significantly. It also seems to [...]]]></description>
			<content:encoded><![CDATA[<p>Recently <a href="http://haacked.com/articles/AboutHaacked.aspx">Phil Haack</a> posted an article on <a href="http://haacked.com/archive/2011/05/09/compiling-mvc-views-in-a-build-environment.aspx">&#8220;Compiling MVC Views In A Build Environment&#8221;</a>, describing how to switch on view compilation.</p>
<p>This can be incredibly useful, surfacing compilation errors across the project rather than relying on picking it up at runtime.</p>
<p>However, I found that it slows compilation down quite significantly. It also seems to lock the VS interface, despite the fact that builds are meant to be in the background.</p>
<p>As a result, I turned it off, but I didn&#8217;t want to abandon it completely. I wanted to make sure that my <a href="http://appharbor.com">AppHarbor</a> builds would fail if a view couldn&#8217;t compile.</p>
<p>The solution is really simple; AppHarbor uses the Release build profile, so only switch compilation on for that profile. This is easily accomplished: add the <code>&lt;MvcBuildViews&gt;true&lt;/MvcBuildViews&gt;</code> code to the <code>PropertyGroup</code> section in the project file that is conditional on the build configuration. For example:</p>
<pre class="brush:xml">
&lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "&gt;
    &lt;!-- other properties elided --&gt;
    &lt;MvcBuildViews&gt;true&lt;/MvcBuildViews&gt;
&lt;/PropertyGroup&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jtnlex.com/blog/2011/05/20/use-build-configurations-to-control-razor-compilation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC error: &#8220;The value &#8216;x&#8217; is not valid for Id&#8221;</title>
		<link>http://jtnlex.com/blog/2011/05/11/asp-net-mvc-error-the-value-x-is-not-valid-for-id/</link>
		<comments>http://jtnlex.com/blog/2011/05/11/asp-net-mvc-error-the-value-x-is-not-valid-for-id/#comments</comments>
		<pubDate>Wed, 11 May 2011 05:27:22 +0000</pubDate>
		<dc:creator>JT</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[programming tips]]></category>

		<guid isPermaLink="false">http://jtnlex.com/blog/?p=125</guid>
		<description><![CDATA[In my current project I&#8217;m using ASP.NET MVC 3 and enjoying it; kudos to Mr Haack and his minions. That said, I just had a problem that took me ages to sort out, though it is trivially simple in retrospect. I kept getting a ModelState error that &#8216;The value &#8220;x&#8221; is not a valid value [...]]]></description>
			<content:encoded><![CDATA[<p>In my current project I&#8217;m using ASP.NET MVC 3 and enjoying it; kudos to <a href="http://haacked.com/">Mr Haack</a> and his minions.</p>
<p>That said, I just had a problem that took me ages to sort out, though it is trivially simple in retrospect. I kept getting a <code>ModelState</code> error that &#8216;The value &#8220;x&#8221; is not a valid value for Id&#8217;. My controller method has a <code>string id</code> parameter, and that was being bound successfully. The error key didn&#8217;t have a path to indicate that it was further down the tree, just &#8220;Id&#8221;. Nuts.</p>
<p>There&#8217;s a behaviour of MVC that will bind route/query/form parameters to fields in object controller parameters. This can be incredibly intuitive, and very useful. You just can&#8217;t forget that MVC works this way.</p>
<p>So in my case, a model in the parameter list has an int Id property, and it was this property that was causing the problem. The solution? <code>[Binding(Exclude="Id")]</code>.</p>
<pre class="brush:csharp">
// controller method definition
public ActionResult CategoryEdit(string id, [Bind(Exclude="Id")] ComplexModelObject model)
{
    return View();
}

// model object definition
public class ComplexModelObject
{
    public int Id { get; set; }
}
</pre>
<p>Thanks, <a href="http://stackoverflow.com/questions/2142990/asp-mvc-the-id-field-is-required-validation-message-on-create-id-not-set-to">stackoverflow</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jtnlex.com/blog/2011/05/11/asp-net-mvc-error-the-value-x-is-not-valid-for-id/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Override templates in an ASP.NET MVC project</title>
		<link>http://jtnlex.com/blog/2011/03/24/override-templates-in-an-asp-net-mvc-project/</link>
		<comments>http://jtnlex.com/blog/2011/03/24/override-templates-in-an-asp-net-mvc-project/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 22:33:28 +0000</pubDate>
		<dc:creator>JT</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[programming tips]]></category>

		<guid isPermaLink="false">http://jtnlex.com/blog/?p=114</guid>
		<description><![CDATA[The built-in templates for ASP.NET MVC get you up and running quickly; but as you build a project it&#8217;s more productive to have it generate output that fits with your requirements, rather than the generic output that will need to be changed each time. Thankfully, this is easily accomplished by copying the default templates into [...]]]></description>
			<content:encoded><![CDATA[<p>The built-in templates for ASP.NET MVC get you up and running quickly; but as you build a project it&#8217;s more productive to have it generate output that fits with your requirements, rather than the generic output that will need to be changed each time.</p>
<p>Thankfully, this is easily accomplished by copying the default templates into your MVC project in a &#8216;<code>CodeTemplates</code>&#8216; folder.</p>
<p>The templates themselves are located deep in the bowels of your Visual Studio installation:<br />
<code>[VS install folder]\Common7\IDE\ItemTemplates\[CSharp | VisualBasic]\Web\[MVC 2 | MVC 3]\CodeTemplates</code></p>
<p>When copied into the root of your MVC project they will be picked up by the &#8216;Create View&#8217; wizard <em>et al</em> and used instead of the default. Note that by default VS will try to run the T4 templates: don&#8217;t let it! If the dialog appears asking to run it, click Cancel (as many times as necessary), then clear the &#8216;Custom Tool&#8217; property of each of the copied files.</p>
<p>See this <a title="T4 Templates: A Quick-Start Guide for ASP.NET MVC Developers" href="http://blogs.msdn.com/b/webdevtools/archive/2009/01/29/t4-templates-a-quick-start-guide-for-asp-net-mvc-developers.aspx">excellent post on template overriding</a> from the Visual Web Developer Team blog on MSDN for a thorough explanation and more details on T4 templates.</p>
<p>Via: <a href="http://stackoverflow.com/questions/1292899/can-the-controller-code-generation-template-be-changed">Stack Overflow</a>, <a href="http://codebetter.com/davidhayden/2009/01/29/overriding-global-t4-templates-in-asp-net-mvc-project-with-per-project-templates/">David Hayden</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jtnlex.com/blog/2011/03/24/override-templates-in-an-asp-net-mvc-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating an Umbraco custom section</title>
		<link>http://jtnlex.com/blog/2010/09/13/creating-an-umbraco-custom-section/</link>
		<comments>http://jtnlex.com/blog/2010/09/13/creating-an-umbraco-custom-section/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 02:11:27 +0000</pubDate>
		<dc:creator>JT</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[umbraco]]></category>

		<guid isPermaLink="false">http://jtnlex.com/blog/?p=101</guid>
		<description><![CDATA[I needed to create a custom section for a project I am working on, which isn&#8217;t well covered in documentation, however the Umbraco community has stepped up and published some excellent guides for getting this done. Below are some links to these high quality articles, and some additional notes. Articles From nibble.be, an example project [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to create a custom section for a project I am working on, which isn&#8217;t well covered in documentation, however the Umbraco community has stepped up and published some excellent guides for getting this done. Below are some links to these high quality articles, and some additional notes.<span id="more-101"></span></p>
<h3>Articles</h3>
<ul>
<li>From nibble.be, an <a href="http://www.nibble.be/?p=71">example project</a></li>
<li>Emanuel Gaspar published a well-written article: <a href="http://www.geckonewmedia.com/blog/2009/8/3/how-to-create-a-custom-section-in-umbraco-4">&#8220;How to create a Custom Section in Umbraco 4&#8243;</a></li>
<li>Morten Christensen (creator of the excellent Google Analytics plugin) had earlier contributed a <a href="http://blog.sitereactor.dk/2009/04/26/google-analytics-for-umbraco-first-installment/">similar article</a></li>
<li><a href="http://www.richardsoeteman.net/default.aspx">Richard Soeteman</a> has some notes on <a href="http://www.richardsoeteman.net/2010/07/02/CompatibilityIssuesBetween40xAnd45ForBackendDevelopers.aspx">compatibility issues for 4.0.x/4.5.x development</a></li>
</ul>
<h3>Notes</h3>
<ul>
<li>For the icon of your custom section (specified in the <code>umbracoApp</code> table), it&#8217;s nicer to use a separate image file instead of updating core CSS files. Put the file in <code>\umbraco\images\tray\</code> and use the file name as the <code>appIcon</code> column value (thanks Nibble). Doing this means you won&#8217;t tread on the toes of another package.</li>
<li>Unless you need a different folder icon, go with the styles when inserting into <code>umbracoAppTree</code>.</li>
<li>Don&#8217;t forget to add the name of your custom section to the language files.</li>
<li>Take note of the compatibility issues with the new 4.5 tree. If you&#8217;re developing for prior 4.x versions, write it to be compatible from the beginning (see the above link).</li>
</ul>
<h3>One more thing</h3>
<p>Lastly, an extra note (courtesy of my colleague, <a href="http://twitter.com/jbreuer1985">Jeroen B</a>): if you want content to appear when you first see the section, or click on the root tree node, you need to configure the dashboard for your section. In the <code>/config/Dashboard.config</code> file, add a <code>section</code> element under the root <code>dashBoard</code> element:</p>
<pre class="brush:xml">&lt;section&gt;
  &lt;areas&gt;
    &lt;area&gt;customsectionname&lt;/area&gt;
  &lt;/areas&gt;

  &lt;tab caption="CustomTabCaptionText"&gt;
    &lt;control&gt;/usercontrols/CustomTabControl.ascx&lt;/control&gt;
  &lt;/tab&gt;
&lt;/section&gt;</pre>
<p>The <code>areas</code> element defines the sections under which this dashboard tab will appear.</p>
]]></content:encoded>
			<wfw:commentRss>http://jtnlex.com/blog/2010/09/13/creating-an-umbraco-custom-section/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET sites not working</title>
		<link>http://jtnlex.com/blog/2010/06/25/asp-net-sites-not-working/</link>
		<comments>http://jtnlex.com/blog/2010/06/25/asp-net-sites-not-working/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 03:52:22 +0000</pubDate>
		<dc:creator>JT</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://jtnlex.com/blog/?p=83</guid>
		<description><![CDATA[I wasted a few hours tracking down an issue the other day where I couldn&#8217;t get an ASP.NET website running on a fresh install of Windows 7 and VS 2010. This website was running on my previous install, making it very frustrating. I spent a lot of time running through event log red herrings before [...]]]></description>
			<content:encoded><![CDATA[<p>I wasted a few hours tracking down an issue the other day where I couldn&#8217;t get an ASP.NET website running on a fresh install of Windows 7 and VS 2010. This website was running on my previous install, making it very frustrating. I spent a lot of time running through event log red herrings before coming across the real solution to my problem.</p>
<p><em>(Updated 2-Jun-2011 &#8211; see the bottom of the post for some notes on 64 bit machines)</em></p>
<p>This problem can manifest itself in a number of ways:</p>
<ul>
<li>You get an error that indicates that ASPX files are mapped to a static file handler</li>
<li>You have multiple versions of the framework installed, your site gives a 404, and you get errors/warnings in the eventlog along the lines of &#8220;<code>Unable to find schema for config section 'system.web.extensions/scripting/scriptResourceHandler'</code>&#8220;, &#8220;<code>Unknown attribute 'type'</code>&#8221; where these errors come from the <code>web.config</code> of the web application you&#8217;re trying to access.</li>
</ul>
<p>There are other possibilities for these errors, but a big possibility is that particular version of the .NET framework that your application is built to use is not registered in IIS.<strong> The most common reason for this is that you install IIS after the framework is installed.</strong> Obviously the installer can&#8217;t do the business when IIS isn&#8217;t around.</p>
<p><em>Note: you can have the correct framework selected in the IIS application pool settings, and your web.config can be perfect but you may still be experiencing this error.</em></p>
<p>IIS looked right to me, but it wasn&#8217;t finding squat. You may not see the ASP section for the website if no framework version is installed, but if say, .NET 4 is configured, and the 3.5 version that comes with 7 isn&#8217;t, your 3.5 sites will mysteriously fail. What fun!</p>
<p>The magic application that allows you to diagnose whether this problem is affecting you is aspnet_regiis.exe. This little tool is found in the framework install folder. <em>Importantly, and counter-intuitively, to check the status of a particular framework version, you need to run the executable that is specific to that version of the framework.</em> For example, to check 1.1, you need to open a command prompt and change to the <code>%windir%\Microsoft.NET\Framework\v1.1.4322</code> folder.</p>
<p>To check that the framework is installed, run the command: <code>aspnet_regiis -lv</code>.</p>
<p>To install this version of the framework, use <code>aspnet_regiis -ir</code>. This installs the framework version, but doesn&#8217;t change the settings of existing IIS application pools.</p>
<p>See the reference topic: <a title="reference link" href="http://msdn.microsoft.com/en-us/library/k6h9cz8h.aspx">ASP.NET IIS Registration Tool (Aspnet_regiis.exe)</a> on MSDN for more information.</p>
<p><strong>Update: </strong>The aspnet_iisreg tool may be in your v4.x folder. And if you&#8217;re running on a 64 bit machine, you need the version in the Framework64 folder. (Thanks to an article on <a href="http://www.hanselman.com/blog/ASPNET4BreakingChangesAndStuffToBeAwareOf.aspx">breaking changes in ASP.NET 4</a> by Scott Hanselman via <a href="http://stackoverflow.com/questions/3738559/iis-manager-cant-configure-net-compilation-on-net-4-applications/3738651#3738651">IIS Manager can&#8217;t configure .NET Compilation on .NET 4 Applications</a> on StackOverflow.)</p>
]]></content:encoded>
			<wfw:commentRss>http://jtnlex.com/blog/2010/06/25/asp-net-sites-not-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sorting with LINQ: don&#8217;t use anonymous types</title>
		<link>http://jtnlex.com/blog/2010/06/18/sorting-with-linq-dont-use-anonymous-types/</link>
		<comments>http://jtnlex.com/blog/2010/06/18/sorting-with-linq-dont-use-anonymous-types/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 02:51:55 +0000</pubDate>
		<dc:creator>JT</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming tips]]></category>

		<guid isPermaLink="false">http://jtnlex.com/blog/?p=80</guid>
		<description><![CDATA[I got the error message "System.ArgumentException: At least one object must implement IComparable." today for the following, seemingly innocuous code. var ordered = order.Lines.OrderBy(l => new { l.AdminCode, l.OrderLineNr}); I thought this was the way to do it; after, that&#8217;s the way that you use Join() for multiple properties. What it was however was a [...]]]></description>
			<content:encoded><![CDATA[<p>I got the error message <code>"System.ArgumentException: At least one object must implement IComparable."</code> today for the following, seemingly innocuous code.</p>
<pre class="brush:csharp">
var ordered = order.Lines.OrderBy(l => new { l.AdminCode, l.OrderLineNr});
</pre>
<p>I thought this was the way to do it; after, that&#8217;s the way that you use <code>Join()</code> for multiple properties. What it was however was a gap in my knowledge. The correct way to do it is:</p>
<pre class="brush:csharp">
var ordered = order.Lines.OrderBy(l => l.AdminCode).ThenBy(l => l.OrderLineNr);
</pre>
<p>This makes sense when you consider that the following are equivalent:</p>
<pre class="brush:csharp">
// methods, then LINQ syntax equivalent
var lines = order.Lines.OrderBy(l => l.AdminCode).ThenBy(l => l.OrderLineNr);
lines = from l in Lines orderby l.AdminCode, l.OrderLineNr select l;

// using a descending modifier
lines = order.Lines.OrderBy(l => l.AdminCode).ThenByDescending(l => l.OrderLineNr);
lines = from l in Lines orderby l.AdminCode, l.OrderLineNr descending select l;
</pre>
<p>Every time I use this kind of thing I consider what this would be if I needed to use an <code>IComparer</code> implementation, and become just that little bit happier.</p>
]]></content:encoded>
			<wfw:commentRss>http://jtnlex.com/blog/2010/06/18/sorting-with-linq-dont-use-anonymous-types/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using asymmetric properties in views</title>
		<link>http://jtnlex.com/blog/2010/06/16/using-asymmetric-properties-in-views/</link>
		<comments>http://jtnlex.com/blog/2010/06/16/using-asymmetric-properties-in-views/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 12:13:34 +0000</pubDate>
		<dc:creator>JT</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming tips]]></category>

		<guid isPermaLink="false">http://jtnlex.com/blog/?p=76</guid>
		<description><![CDATA[Many people separate their business logic and view classes into two or more separate assemblies. This gives rise to the ability to use an asymmetric set for view properties that aren&#8217;t meant to be accessible. Simply put: public string SomeProperty { get; internal set; } The internal modifier means that this property is only accessible [...]]]></description>
			<content:encoded><![CDATA[<p>Many people separate their business logic and view classes into two or more separate assemblies. This gives rise to the ability to use an asymmetric set for view properties that aren&#8217;t meant to be accessible.</p>
<p>Simply put:</p>
<pre class="brush:csharp">
public string SomeProperty { get; internal set; }
</pre>
<p>The <code>internal</code> modifier means that this property is only accessible to classes in the same assembly. Obviously asymmetric properties in general are applicable in other scenarios. Note too that while this is using the compact property syntax, the same principle holds for explicit setters.</p>
]]></content:encoded>
			<wfw:commentRss>http://jtnlex.com/blog/2010/06/16/using-asymmetric-properties-in-views/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Docs API: get all spreadsheets/docs in a folder</title>
		<link>http://jtnlex.com/blog/2010/06/09/google-docs-api-get-all-spreadsheetsdocs-in-a-folder/</link>
		<comments>http://jtnlex.com/blog/2010/06/09/google-docs-api-get-all-spreadsheetsdocs-in-a-folder/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 13:39:22 +0000</pubDate>
		<dc:creator>JT</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google apps]]></category>
		<category><![CDATA[google docs]]></category>
		<category><![CDATA[google docs api]]></category>
		<category><![CDATA[programming tips]]></category>

		<guid isPermaLink="false">http://jtnlex.com/blog/?p=67</guid>
		<description><![CDATA[It&#8217;s easy enough to get a list of spreadsheets for a user, or a list of folders, but there&#8217;s a trick to getting the contents of a folder. The first part of the trick is to ignore the category. Firstly, because it&#8217;s removed in version 3.0 of the API, and secondly because it filters by [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s easy enough to get a list of spreadsheets for a user, or a list of folders, but there&#8217;s a trick to getting the contents of a folder.</p>
<p>The first part of the trick is to ignore the category. Firstly, because it&#8217;s removed in version 3.0 of the API, and secondly because it filters by name. This means that if you have 2 folders with the same name you&#8217;ll get dodgey results.</p>
<p>To do it right?<br />
<span id="more-67"></span></p>
<pre class="brush:csharp">
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Documents;

// snipped method declaration etc

var docService = new DocumentsService("company-app-version");
docService.setUserCredentials("username", "password");

var folderList = docService.Query(new FolderQuery());
var fLinks = folderList.Entries.Select(e =>
    new
    {
        // note how to get the document Id of the folder
        Id = DocumentsListQuery.DocumentId(e.Id.AbsoluteUri),
        Name = e.Title.Text
    });

foreach (var folder in fLinks)
{
    Console.WriteLine("Folder {0}", folder.Name);

    var fileList = docService.Query(
        new SpreadsheetQuery()
        {
            // setting the base address to the folder's URI restricts your results
            BaseAddress = DocumentsListQuery.folderBaseUri + folder.Id
        });

    foreach (var file in fileList.Entries)
    {
        Console.WriteLine(" - {0}", file.Title.Text);
    }
}
</pre>
<p>This will give you a list of the files in all your folders. Note you can get a list of all files in all folders a lot easier than this. That&#8217;s not the point: use this technique when you <em>don&#8217;t</em> want to get the whole list and filter after the fact.</p>
<p>Pertinent points:</p>
<ul>
<li>Line 15: getting the Id of the folder from its URI</li>
<li>Line 27: setting the base URI of the query to be the folder prefix and the folder&#8217;s Id.</li>
</ul>
<p>I wish I&#8217;d found this quicker&#8230;</p>
<p>(Updated to add clarification about example, and a couple of comments in the code)</p>
]]></content:encoded>
			<wfw:commentRss>http://jtnlex.com/blog/2010/06/09/google-docs-api-get-all-spreadsheetsdocs-in-a-folder/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert file path to file URL</title>
		<link>http://jtnlex.com/blog/2010/05/21/convert-file-path-to-file-url/</link>
		<comments>http://jtnlex.com/blog/2010/05/21/convert-file-path-to-file-url/#comments</comments>
		<pubDate>Fri, 21 May 2010 06:59:38 +0000</pubDate>
		<dc:creator>JT</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming tips]]></category>

		<guid isPermaLink="false">http://jtnlex.com/blog/?p=63</guid>
		<description><![CDATA[A very short note: I was trying to find an analogue to Java&#8217;s File.toURI().toURL() method in .NET, looking through System.IO et al, and not finding it on the lazyweb. To my surprise, all you need use is UriBuilder: new UriBuilder(@"c:\path\to\file.txt").ToString(); This will output &#8220;file://c:/path/to/file.txt&#8220;. Simple, but far too much time wasted finding it&#8230;]]></description>
			<content:encoded><![CDATA[<p>A very short note: I was trying to find an analogue to Java&#8217;s <code>File.toURI().toURL()</code> method in .NET, looking through <code>System.IO</code> et al, and not finding it on the lazyweb.</p>
<p>To my surprise, all you need use is UriBuilder:</p>
<pre class="brush:csharp">
new UriBuilder(@"c:\path\to\file.txt").ToString();
</pre>
<p>This will output &#8220;<code>file://c:/path/to/file.txt</code>&#8220;. Simple, but far too much time wasted finding it&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://jtnlex.com/blog/2010/05/21/convert-file-path-to-file-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

