<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en" xml:base="http://jtnlex.com/blog/wp-atom.php">
	<title type="text">Purposeful Procrastination</title>
	<subtitle type="text">It'll be useful someday, surely.</subtitle>

	<updated>2010-06-25T03:52:22Z</updated>

	<link rel="alternate" type="text/html" href="http://jtnlex.com/blog" />
	<id>http://jtnlex.com/blog/feed/atom/</id>
	

	<generator uri="http://wordpress.org/" version="3.0">WordPress</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/purposeful-procrastination" /><feedburner:info uri="purposeful-procrastination" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fpurposeful-procrastination" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fpurposeful-procrastination" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/purposeful-procrastination" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fpurposeful-procrastination" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><entry>
		<author>
			<name>JT</name>
					</author>
		<title type="html"><![CDATA[ASP.NET sites not working]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/purposeful-procrastination/~3/EIXkHXUAvUg/" />
		<id>http://jtnlex.com/blog/?p=83</id>
		<updated>2010-06-25T03:52:22Z</updated>
		<published>2010-06-25T03:52:22Z</published>
		<category scheme="http://jtnlex.com/blog" term="Uncategorized" />		<summary type="html"><![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 [...]]]></summary>
		<content type="html" xml:base="http://jtnlex.com/blog/2010/06/25/asp-net-sites-not-working/">&lt;p&gt;I wasted a few hours tracking down an issue the other day where I couldn&amp;#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.&lt;/p&gt;
&lt;p&gt;This problem can manifest itself in a number of ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You get an error that indicates that ASPX files are mapped to a static file handler&lt;/li&gt;
&lt;li&gt;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 &amp;#8220;&lt;code&gt;Unable to find schema for config section 'system.web.extensions/scripting/scriptResourceHandler'&lt;/code&gt;&amp;#8220;, &amp;#8220;&lt;code&gt;Unknown attribute 'type'&lt;/code&gt;&amp;#8221; where these errors come from the &lt;code&gt;web.config&lt;/code&gt; of the web application you&amp;#8217;re trying to access.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are other possibilities for these errors, but a big possibility is that particular version of the .NET framework that your application is not registered in IIS. The most common reason for this is that you install IIS after the framework is installed. Obviously the installer can&amp;#8217;t do the business when IIS isn&amp;#8217;t around.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;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.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;IIS looked right to me, but it wasn&amp;#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&amp;#8217;t, your 3.5 sites will mysteriously fail. What fun!&lt;/p&gt;
&lt;p&gt;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. &lt;em&gt;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.&lt;/em&gt; For example, to check 1.1, you need to open a command prompt and change to the &lt;code&gt;%windir%\Microsoft.NET\Framework\v1.1.4322&lt;/code&gt; folder.&lt;/p&gt;
&lt;p&gt;To check that the framework is installed, run the command: &lt;code&gt;aspnet_regiis -lv&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To install this version of the framework, use &lt;code&gt;aspnet_regiis -ir&lt;/code&gt;. This installs the framework version, but doesn&amp;#8217;t change the settings of existing IIS application pools.&lt;/p&gt;
&lt;p&gt;See the reference topic: &lt;a title="reference link" href="http://msdn.microsoft.com/en-us/library/k6h9cz8h.aspx"&gt;ASP.NET IIS Registration Tool (Aspnet_regiis.exe)&lt;/a&gt; on MSDN for more information.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/purposeful-procrastination/~4/EIXkHXUAvUg" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jtnlex.com/blog/2010/06/25/asp-net-sites-not-working/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jtnlex.com/blog/2010/06/25/asp-net-sites-not-working/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jtnlex.com/blog/2010/06/25/asp-net-sites-not-working/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>JT</name>
					</author>
		<title type="html"><![CDATA[Sorting with LINQ: don&#8217;t use anonymous types]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/purposeful-procrastination/~3/VO9yuryYajE/" />
		<id>http://jtnlex.com/blog/?p=80</id>
		<updated>2010-06-18T02:51:55Z</updated>
		<published>2010-06-18T02:51:55Z</published>
		<category scheme="http://jtnlex.com/blog" term="Uncategorized" /><category scheme="http://jtnlex.com/blog" term="c#" /><category scheme="http://jtnlex.com/blog" term="programming tips" />		<summary type="html"><![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 [...]]]></summary>
		<content type="html" xml:base="http://jtnlex.com/blog/2010/06/18/sorting-with-linq-dont-use-anonymous-types/">&lt;p&gt;I got the error message &lt;code&gt;"System.ArgumentException: At least one object must implement IComparable."&lt;/code&gt; today for the following, seemingly innocuous code.&lt;/p&gt;
&lt;pre class="brush:csharp"&gt;
var ordered = order.Lines.OrderBy(l =&gt; new { l.AdminCode, l.OrderLineNr});
&lt;/pre&gt;
&lt;p&gt;I thought this was the way to do it; after, that&amp;#8217;s the way that you use &lt;code&gt;Join()&lt;/code&gt; for multiple properties. What it was however was a gap in my knowledge. The correct way to do it is:&lt;/p&gt;
&lt;pre class="brush:csharp"&gt;
var ordered = order.Lines.OrderBy(l =&gt; l.AdminCode).ThenBy(l =&gt; l.OrderLineNr);
&lt;/pre&gt;
&lt;p&gt;This makes sense when you consider that the following are equivalent:&lt;/p&gt;
&lt;pre class="brush:csharp"&gt;
// methods, then LINQ syntax equivalent
var lines = order.Lines.OrderBy(l =&gt; l.AdminCode).ThenBy(l =&gt; l.OrderLineNr);
lines = from l in Lines orderby l.AdminCode, l.OrderLineNr select l;

// using a descending modifier
lines = order.Lines.OrderBy(l =&gt; l.AdminCode).ThenByDescending(l =&gt; l.OrderLineNr);
lines = from l in Lines orderby l.AdminCode, l.OrderLineNr descending select l;
&lt;/pre&gt;
&lt;p&gt;Every time I use this kind of thing I consider what this would be if I needed to use an &lt;code&gt;IComparer&lt;/code&gt; implementation, and become just that little bit happier.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/purposeful-procrastination/~4/VO9yuryYajE" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jtnlex.com/blog/2010/06/18/sorting-with-linq-dont-use-anonymous-types/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jtnlex.com/blog/2010/06/18/sorting-with-linq-dont-use-anonymous-types/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jtnlex.com/blog/2010/06/18/sorting-with-linq-dont-use-anonymous-types/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>JT</name>
					</author>
		<title type="html"><![CDATA[Using asymmetric properties in views]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/purposeful-procrastination/~3/EvWMS-o9qSA/" />
		<id>http://jtnlex.com/blog/?p=76</id>
		<updated>2010-06-16T12:13:34Z</updated>
		<published>2010-06-16T12:13:34Z</published>
		<category scheme="http://jtnlex.com/blog" term=".NET" /><category scheme="http://jtnlex.com/blog" term="c#" /><category scheme="http://jtnlex.com/blog" term="programming tips" />		<summary type="html"><![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 [...]]]></summary>
		<content type="html" xml:base="http://jtnlex.com/blog/2010/06/16/using-asymmetric-properties-in-views/">&lt;p&gt;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&amp;#8217;t meant to be accessible.&lt;/p&gt;
&lt;p&gt;Simply put:&lt;/p&gt;
&lt;pre class="brush:csharp"&gt;
public string SomeProperty { get; internal set; }
&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;internal&lt;/code&gt; 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.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/purposeful-procrastination/~4/EvWMS-o9qSA" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jtnlex.com/blog/2010/06/16/using-asymmetric-properties-in-views/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jtnlex.com/blog/2010/06/16/using-asymmetric-properties-in-views/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jtnlex.com/blog/2010/06/16/using-asymmetric-properties-in-views/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>JT</name>
					</author>
		<title type="html"><![CDATA[Google Docs API: get all spreadsheets/docs in a folder]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/purposeful-procrastination/~3/zVtqldDQaWI/" />
		<id>http://jtnlex.com/blog/?p=67</id>
		<updated>2010-06-10T01:39:24Z</updated>
		<published>2010-06-09T13:39:22Z</published>
		<category scheme="http://jtnlex.com/blog" term=".NET" /><category scheme="http://jtnlex.com/blog" term="c#" /><category scheme="http://jtnlex.com/blog" term="google" /><category scheme="http://jtnlex.com/blog" term="google apps" /><category scheme="http://jtnlex.com/blog" term="google docs" /><category scheme="http://jtnlex.com/blog" term="google docs api" /><category scheme="http://jtnlex.com/blog" term="programming tips" />		<summary type="html"><![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 [...]]]></summary>
		<content type="html" xml:base="http://jtnlex.com/blog/2010/06/09/google-docs-api-get-all-spreadsheetsdocs-in-a-folder/">&lt;p&gt;It&amp;#8217;s easy enough to get a list of spreadsheets for a user, or a list of folders, but there&amp;#8217;s a trick to getting the contents of a folder.&lt;/p&gt;
&lt;p&gt;The first part of the trick is to ignore the category. Firstly, because it&amp;#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&amp;#8217;ll get dodgey results.&lt;/p&gt;
&lt;p&gt;To do it right?&lt;br /&gt;
&lt;span id="more-67"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;pre class="brush:csharp"&gt;
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 =&gt;
    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);
    }
}
&lt;/pre&gt;
&lt;p&gt;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&amp;#8217;s not the point: use this technique when you &lt;em&gt;don&amp;#8217;t&lt;/em&gt; want to get the whole list and filter after the fact.&lt;/p&gt;
&lt;p&gt;Pertinent points:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Line 15: getting the Id of the folder from its URI&lt;/li&gt;
&lt;li&gt;Line 27: setting the base URI of the query to be the folder prefix and the folder&amp;#8217;s Id.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I wish I&amp;#8217;d found this quicker&amp;#8230;&lt;/p&gt;
&lt;p&gt;(Updated to add clarification about example, and a couple of comments in the code)&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/purposeful-procrastination/~4/zVtqldDQaWI" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jtnlex.com/blog/2010/06/09/google-docs-api-get-all-spreadsheetsdocs-in-a-folder/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jtnlex.com/blog/2010/06/09/google-docs-api-get-all-spreadsheetsdocs-in-a-folder/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jtnlex.com/blog/2010/06/09/google-docs-api-get-all-spreadsheetsdocs-in-a-folder/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>JT</name>
					</author>
		<title type="html"><![CDATA[Convert file path to file URL]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/purposeful-procrastination/~3/ERouft-j2H0/" />
		<id>http://jtnlex.com/blog/?p=63</id>
		<updated>2010-05-21T06:59:38Z</updated>
		<published>2010-05-21T06:59:38Z</published>
		<category scheme="http://jtnlex.com/blog" term=".NET" />		<summary type="html"><![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;]]></summary>
		<content type="html" xml:base="http://jtnlex.com/blog/2010/05/21/convert-file-path-to-file-url/">&lt;p&gt;A very short note: I was trying to find an analogue to Java&amp;#8217;s &lt;code&gt;File.toURI().toURL()&lt;/code&gt; method in .NET, looking through &lt;code&gt;System.IO&lt;/code&gt; et al, and not finding it on the lazyweb.&lt;/p&gt;
&lt;p&gt;To my surprise, all you need use is UriBuilder:&lt;/p&gt;
&lt;pre class="brush:csharp"&gt;
new UriBuilder(@"c:\path\to\file.txt").ToString();
&lt;/pre&gt;
&lt;p&gt;This will output &amp;#8220;&lt;code&gt;file://c:/path/to/file.txt&lt;/code&gt;&amp;#8220;. Simple, but far too much time wasted finding it&amp;#8230;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/purposeful-procrastination/~4/ERouft-j2H0" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jtnlex.com/blog/2010/05/21/convert-file-path-to-file-url/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jtnlex.com/blog/2010/05/21/convert-file-path-to-file-url/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jtnlex.com/blog/2010/05/21/convert-file-path-to-file-url/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>JT</name>
					</author>
		<title type="html"><![CDATA[*Reset*]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/purposeful-procrastination/~3/9TxVd8S5Mdg/" />
		<id>http://jtnlex.com/blog/?p=58</id>
		<updated>2010-05-17T00:59:58Z</updated>
		<published>2010-05-17T00:58:05Z</published>
		<category scheme="http://jtnlex.com/blog" term="Uncategorized" />		<summary type="html"><![CDATA[I originally started this blog as a way to push back some of the discoveries I had to the wider community in the hope that it would help prevent others making my (countless) mistakes. Who knows if the second try will work&#8230;]]></summary>
		<content type="html" xml:base="http://jtnlex.com/blog/2010/05/17/reset/">&lt;p&gt;I originally started this blog as a way to push back some of the discoveries I had to the wider community in the hope that it would help prevent others making my (countless) mistakes. Who knows if the second try will work&amp;#8230;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/purposeful-procrastination/~4/9TxVd8S5Mdg" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jtnlex.com/blog/2010/05/17/reset/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jtnlex.com/blog/2010/05/17/reset/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jtnlex.com/blog/2010/05/17/reset/</feedburner:origLink></entry>
	</feed>
