<?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>Chris Fulstow &#187; vb.net</title>
	<atom:link href="http://chrisfulstow.com/category/vb-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://chrisfulstow.com</link>
	<description>ASP.NET Tech Lead and Web Developer</description>
	<lastBuildDate>Sat, 05 Jun 2010 01:32:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>.NET Framework 3.5 Reference Poster</title>
		<link>http://chrisfulstow.com/net-framework-35-reference-poster/</link>
		<comments>http://chrisfulstow.com/net-framework-35-reference-poster/#comments</comments>
		<pubDate>Sun, 27 Jan 2008 06:45:14 +0000</pubDate>
		<dc:creator>Chris Fulstow</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://3poundmass.wordpress.com/?p=97</guid>
		<description><![CDATA[This slick .NET 3.5 reference poster is available as a free download from MSDN.  It&#8217;s got the most commonly used types and namespaces in the framework.  A great quick reference for any .NET developer&#8217;s office wall:

As it&#8217;s getting progressively harder to keep up with .NET&#8217;s continutally expanding scope, this poster is a handy reminder <a href="http://chrisfulstow.com/net-framework-35-reference-poster/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>This slick <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7b645f3a-6d22-4548-a0d8-c2a27e1917f8&amp;DisplayLang=en">.NET 3.5 reference poster</a> is available as a <strong>free download</strong> from MSDN.  It&#8217;s got the most commonly used <strong>types and namespaces</strong> in the framework.  A great quick reference for any .NET developer&#8217;s office wall:</p>
<p><a title=".NET 3.5 Reference Poster" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7b645f3a-6d22-4548-a0d8-c2a27e1917f8&amp;DisplayLang=en"><img style="border: 1px solid #dddddd;" src="http://chrisfulstow.com/wp-content/uploads/2007/12/dotnet-poster.png" alt=".NET 3.5 Poster" /></a></p>
<p>As it&#8217;s getting progressively harder to keep up with <a href="http://asp.net/downloads/3.5-extensions/">.NET&#8217;s continutally expanding scope</a>, this poster is a handy reminder of what&#8217;s included.  It shows which classes were added in .NET 3.0, and which in .NET 3.5.</p>
<p>There&#8217;s a broad cross-section across all areas of the .NET Framework:</p>
<ul>
<li>ASP.NET</li>
<li>WinForms and WPF</li>
<li>Communications and Workflow</li>
<li>Data, XML and LINQ</li>
<li>Fundamentals</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Printing</strong></span></p>
<p>The hi-res version is Microsoft <a href="http://en.wikipedia.org/wiki/XML_Paper_Specification">XPS</a> format, so if you&#8217;re not using Vista or Office 2007 then you might want the <a href="http://www.microsoft.com/whdc/xps/viewxps.mspx">Microsoft XPS Viewer</a>. Also, for &#8216;easy printing&#8217;, there&#8217;s a 16 page 4&#215;4 version, but remember: &#8217;some assembly is required if you choose this print method&#8217;, so remember to ask an adult for help with the scissors.</p>
<p>My local print shop printed and laminated the PDF version onto A1, which is easily hi-res enough and looks great.</p>
<p><span style="text-decoration: underline;"><strong>Other .NET Reference Posters</strong></span></p>
<p>There are a few other reference posters on MSDN, in particular I like the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=811d8ad6-8d48-4684-b08c-686462d58a56&amp;DisplayLang=en">Silverlight Developer Reference</a>, and <strong>keyboard shortcuts for Visual Studio 2008</strong>, available for both <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e5f902a8-5bb5-4cc6-907e-472809749973&amp;DisplayLang=en">C# </a>and <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=255b8cf1-f6bd-4b55-bb42-dd1a69315833&amp;DisplayLang=en">Visual Basic</a>.</p>
<p>(Thanks to <a href="http://blogs.msdn.com/cbowen/archive/2007/12/09/got-tech-posters.aspx">Chris Bowen</a> for the tip off.)</p>
]]></content:encoded>
			<wfw:commentRss>http://chrisfulstow.com/net-framework-35-reference-poster/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Reading other people&#039;s .NET code</title>
		<link>http://chrisfulstow.com/reading-other-peoples-net-code/</link>
		<comments>http://chrisfulstow.com/reading-other-peoples-net-code/#comments</comments>
		<pubDate>Mon, 27 Aug 2007 08:38:35 +0000</pubDate>
		<dc:creator>Chris Fulstow</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[codeplex]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://3poundmass.wordpress.com/2007/08/27/reading-other-peoples-net-code/</guid>
		<description><![CDATA[One thing that makes HTML easy to learn is the abundance of examples. You can go to any old website and view the source to see how it&#8217;s put together, or look through templates on a site like Open Source Web Design or Open Source Templates. It&#8217;s easy find examples of good (and bad) practice.
Scott Hanselman&#8217;s <a href="http://chrisfulstow.com/reading-other-peoples-net-code/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>One thing that makes HTML easy to learn is the abundance of examples. You can go to any old website and view the source to see how it&#8217;s put together, or look through templates on a site like <a href="http://www.oswd.org/">Open Source Web Design</a> or <a href="http://opensourcetemplates.org/">Open Source Templates</a>. It&#8217;s easy find examples of good (and bad) practice.</p>
<p>Scott Hanselman&#8217;s article <a href="http://www.hanselman.com/blog/ReadingToBeABetterDeveloperTheCoding4FunDevKit.aspx">Reading to Be a Better Developer</a> got me wondering why we don&#8217;t do this more with <strong>.NET code</strong>, and the problem for me seems to be finding good code examples. Scott recommends looking at the <a href="http://www.codeplex.com/C4FDevKit">Coding4Fun Developer Kit</a>, but I wanted something more specific to web development.</p>
<p>So here are a few places I found ASP.NET source code that&#8217;s worth studying and learning from.</p>
<p><strong>Microsoft Enterprise Library</strong></p>
<p>A great place to start is the <a href="http://msdn2.microsoft.com/en-us/practices/bb190359.aspx">application blocks</a> in Microsoft&#8217;s <a href="http://www.microsoft.com/downloads/details.aspx?familyid=4c557c63-708f-4280-8f0c-637481c31718&amp;displaylang=en">Enterprise Library</a>. These are application service components designed to follow Microsoft best practices and include modules for caching, cryptography, data access, exception handling, logging, policy injection, security and validation.</p>
<p><strong>Website Starter Kits</strong></p>
<p>Another good place to look is the <a href="http://www.asp.net/downloads/starter-kits/">ASP.NET Starter Kit Websites</a>, a collection of working ASP.NET demos that can be examined or built on. They cover DotNetNuke, e-commerce with PayPal, blogging, project time management, media library and plenty more.</p>
<p><strong>Codeplex</strong></p>
<p>Lastly <a href="http://www.codeplex.com/">Codeplex</a>, Microsoft&#8217;s open source project hosting site. There&#8217;s so much goodness here it&#8217;s hard know where to start, so try browsing the most popular or active projects to start. Here are the top ten that caught my eye:</p>
<ul>
<li><span><a href="http://www.codeplex.com/blogengine">BlogEngine.NET</a><br />
Full featured blog engine targeted at .NET developers. It is light weight and very simple to modify and extend.</span></li>
<li><a href="http://www.codeplex.com/umbraco">Umbraco</a><br />
Simple, flexible and friendly ASP.NET CMS</li>
<li><a href="http://www.codeplex.com/DinnerNow">DinnerNow</a><br />
Sample marketplace application designed to demonstrate how you can develop a connected application using IIS7, ASP.NET Ajax Extensions, Linq, WCF, WF, WPF, Powershell, and the .NET Compact Framework.</li>
<li><a href="http://www.codeplex.com/CKS">Community Kit for SharePoint</a><br />
<span>Set of best practices, templates, Web Parts, tools, and source code for creating a community website based on SharePoint.<br />
</span></li>
<li><span><a href="http://www.codeplex.com/FacebookToolkit">Facebook Developer Toolkit</a> and <a href="http://www.codeplex.com/FacebookNET">Facebook.NET</a><br />
.NET wrappers and libraries for the Facebook API.</span></li>
<li><span><a href="http://www.codeplex.com/DbEntry">DbEntry.Net</a><br />
Lightweight, high performance Object Relational Mapping (ORM) database access compnent for .NET 2.0.</span></li>
<li><span><a href="http://www.codeplex.com/publicdomain">PublicDomain</a><br />
</span><span>.NET</span><span> packages for time zone support, logging, dynamic code evaluation, GAC API, unzipping, RSS, Atom, OPML, screen scraping, and utilities for strings, arrays and cryptography.</span></li>
<li><span><a href="http://www.codeplex.com/ASPNETRSSToolkit">ASP.NET RSS Toolkit</a><br />
Gives ASP.NET applications the ability to consume and publish to RSS feeds.</span></li>
<li><a href="http://www.codeplex.com/NGenerics">NGenerics</a><br />
Class library providing generic data structures and algorithms not implemented in the standard .NET framework</li>
<li><a href="http://www.codeplex.com/htmlagilitypack">Html Agility Pack</a><br />
Agile HTML parser that builds a read/write DOM and supports plain XPath or XSLT. The parser is very tolerant with &#8220;real world&#8221; malformed HTML. The object model is very similar to System.Xml, but for HTML documents.</li>
</ul>
<p>If you know any other places to find good quality .NET source code then please leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrisfulstow.com/reading-other-peoples-net-code/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Task List comments in Visual Studio</title>
		<link>http://chrisfulstow.com/task-list-comments-in-visual-studio/</link>
		<comments>http://chrisfulstow.com/task-list-comments-in-visual-studio/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 02:46:18 +0000</pubDate>
		<dc:creator>Chris Fulstow</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://3poundmass.wordpress.com/2007/08/23/task-list-comments-in-visual-studio/</guid>
		<description><![CDATA[Here&#8217;s a quick Visual Studio tip.  You can embed useful notes and reminders in code using Task List comments like this:
// TODO: fix catastrophic memory leak
These notes will automatically appear in the Visual Studio Task List, which you can open with the shortcut Ctrl+W, T or by selecting View &#8211; Task List from the <a href="http://chrisfulstow.com/task-list-comments-in-visual-studio/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick <strong>Visual Studio</strong> tip.  You can embed useful notes and reminders in code using <a href="http://msdn2.microsoft.com/en-US/library/zce12xx2(VS.80).aspx">Task List comments</a> like this:</p>
<pre style="margin:0;"><span style="color:green;">// TODO: fix catastrophic memory leak</span></pre>
<p>These notes will automatically appear in the Visual Studio <a href="http://msdn2.microsoft.com/en-us/library/170k1bbs(VS.80).aspx">Task List</a>, which you can open with the shortcut <strong>Ctrl+W, T</strong> or by selecting <strong>View &#8211; Task List</strong> from the main menu bar.</p>
<p><img src="http://3poundmass.files.wordpress.com/2007/08/vs-task-list.png" alt="Visual Studio Task List" /></p>
<p>Visual Studio also supports two other comment tokens, HACK and UNDONE.  You can even <a href="http://msdn2.microsoft.com/en-US/library/ekwz6akh(VS.80).aspx">add your own custom comment tokens</a> in:</p>
<p><strong>Options &#8211; Environment &#8211; Task List</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrisfulstow.com/task-list-comments-in-visual-studio/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>.NET Coding Guidelines &#8211; SQL Injection</title>
		<link>http://chrisfulstow.com/coding-guidelines-sql-injection/</link>
		<comments>http://chrisfulstow.com/coding-guidelines-sql-injection/#comments</comments>
		<pubDate>Fri, 03 Aug 2007 00:05:13 +0000</pubDate>
		<dc:creator>Chris Fulstow</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sql server]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://3poundmass.wordpress.com/2007/08/03/coding-guidelines-sql-injection/</guid>
		<description><![CDATA[In the first of my guidelines for deadbeat developers, I asked why you&#8217;re too lazy to comment your code.  This time, I&#8217;d like to investigate why you build software that&#8217;s catastrophically insecure.
Part 2 &#8211; Protect against SQL injection in .NET
This code will look familiar because it&#8217;s the sort of sloppy mistake you make all <a href="http://chrisfulstow.com/coding-guidelines-sql-injection/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>In the first of my guidelines for deadbeat developers, I asked why you&#8217;re too lazy to <a href="/2007/07/26/coding-guidelines-commenting/">comment your code</a>.  This time, I&#8217;d like to investigate why you build software that&#8217;s catastrophically insecure.</p>
<h2>Part 2 &#8211; Protect against SQL injection in .NET</h2>
<p>This code will look familiar because it&#8217;s the sort of sloppy mistake you make all the time.</p>
<pre><span style="color:blue;">string</span> productId = Request.QueryString[<span style="color:#a31515;">"ProductId"</span>];
<span style="color:blue;">string</span> sql = <span style="color:#a31515;">"delete Products where Id="</span> + productId;
<span style="color:#2b91af;">SqlCommand</span> cmd = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlCommand</span>(sql);
cmd.ExecuteNonQuery();</pre>
<p>Your feeble imagination doesn&#8217;t stretch far enough to consider what happens when a mischievous user sets productId to, say, &#8220;1 OR 1=1&#8243;.  You merrily build the query, complete with unverified user input, and execute it against the database.</p>
<pre><span style="color:blue;">delete</span> Products <span style="color:blue;">where</span> Id=1 <span style="color:blue;">OR</span> 1=1</pre>
<p>Oh dear, where did all your products go?</p>
<p>A vigilant SQL Server DBA can thwart your stupidity at the database by restricting your access.  By assigning your login to the <a href="http://msdn2.microsoft.com/en-us/library/ms187916.aspx" target="_blank">db_denydatareader</a> and <a href="http://msdn2.microsoft.com/en-us/library/ms188308.aspx" target="_blank">db_denydatawriter</a> roles, you can thankfully be prevented from running any SELECT, DELETE, INSERT or UPDATE queries whatsoever.</p>
<p><img src="http://3poundmass.files.wordpress.com/2007/07/denied.png" alt="SQL Server roles" /></p>
<p>Since you can&#8217;t be trusted, the DBA should give you permissions to execute only the stored-procedures and UDFs you need.  This is the <a href="http://en.wikipedia.org/wiki/Principle_of_least_privilege">principle of least privilege</a>.</p>
<p><img src="http://3poundmass.files.wordpress.com/2007/07/grant-exec1.png" alt="Grant SQL exec permission" /></p>
<p>Parameterised stored-procedures are usually safe from SQL injection because they validate the type and size of the inputs.  These inputs are evaluated as values only, and not executed as part of the SQL statement.  But there is one exception.  When you build SQL dynamically inside the stored-procedure.</p>
<p><span style="color:darkred;">sp_executesql</span> <span style="color:red;">&#8217;select * from Products where Id in &#8216;</span> + @List</p>
<p>This line is from a real stored-procedure I saw last week, @List is a varchar parameter containing something like &#8220;(1,2,3)&#8221;. <span style="color:darkred;"></span>And, of course, the values for @List came from unverified user input.  If you absolutely have to use dynamic SQL then at least clean the inputs and remove or escape anything that could be potentially dangerous.</p>
<p><strong>Read more about SQL injection:</strong></p>
<ul>
<li><a href="http://msdn2.microsoft.com/en-us/library/ms998271.aspx">How To: Protect From SQL Injection in ASP.NET</a></li>
<li><a href="http://msdn2.microsoft.com/en-us/library/ms161953.aspx">SQL Server BOL: SQL Injection</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://chrisfulstow.com/coding-guidelines-sql-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET Coding Guidelines &#8211; Commenting</title>
		<link>http://chrisfulstow.com/coding-guidelines-commenting/</link>
		<comments>http://chrisfulstow.com/coding-guidelines-commenting/#comments</comments>
		<pubDate>Thu, 26 Jul 2007 10:04:48 +0000</pubDate>
		<dc:creator>Chris Fulstow</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://3poundmass.wordpress.com/2007/07/26/coding-guidelines-commenting/</guid>
		<description><![CDATA[Let&#8217;s be honest, there&#8217;s only one main purpose to blogging.  To translate concentrated rage into HTML.  To that end, I humbly offer a series of guidelines to you shoddy developers who regularly infect my source tree with your twisted code-wrongs.
Part 1 — Comment your .NET code
You might very well think that. I couldn&#8217;t <a href="http://chrisfulstow.com/coding-guidelines-commenting/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s be honest, there&#8217;s only one main purpose to blogging.  To translate concentrated rage into HTML.  To that end, I humbly offer a series of guidelines to you shoddy developers who regularly infect my source tree with your twisted code-wrongs.</p>
<h2>Part 1 — Comment your .NET code</h2>
<p><q>You might very well think that. I couldn&#8217;t possibly comment.</q><br />
— <a href="http://en.wikipedia.org/wiki/Francis_Urquhart" target="_blank">Francis Urquhart</a></p>
<p>By glancing at your uncommented code I can tell instantly that you&#8217;re either an amateur or, more likely, a lazy and selfish sociopath.  It&#8217;s not like I&#8217;m asking you to write a novel.    Would it really impede your productivity so much that you can&#8217;t find time to furnish your garbled, obfuscated nonsense with some sort of mitigating explanation?    Oh, and when I tell you to start adding comments, I don&#8217;t expect you to start littering code with superfluous crap like:</p>
<pre style="margin:0;">populateControls();       <span style="color:green;">// populate the controls</span></pre>
<pre style="margin:0;"><span style="color:blue;">string</span> name = getName();  <span style="color:green;">// set the name</span></pre>
<p>Comment as you go along, or you&#8217;ll forget.  If you&#8217;re so inclined, use comments to structure your functional design <em>before</em> you write code, this is the <a href="http://www.coderookie.com/2006/tutorial/the-pseudocode-programming-process/">Pseudocode Programming Process</a>.  As a general rule, comment <em>what</em> your code is doing, and <em>why</em> it&#8217;s doing it.  I should already be able to see how your code works, because you&#8217;ve used <em>meaningful</em> and <em>precise</em> names for your classes, functions and variables.</p>
<pre style="margin:0;"><span style="color:green;">// create a SqlConnection object using connectionString</span></pre>
<pre style="margin:0;"><span style="color:#2b91af;">SqlConnection</span> cnn = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlConnection</span>(connectionString);</pre>
<p>I can see you&#8217;re using a SqlConnection because the programming syntax conveniently forces you to include the class type in its variable declaration.  It is also very clear from the code that you&#8217;re passing connectionString as a parameter.  The bigger picture is a mystery.  What is your <em>intent</em>?  Why are you connecting to the database?  What data are you expecting back?  If these things aren&#8217;t clear then explain.</p>
<p>Don&#8217;t comment every single line, instead give a brief summary for each block of related code.  If you&#8217;re working on an API then use a documentation generator like <a href="http://java.sun.com/j2se/javadoc/">Javadoc</a> or <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=E82EA71D-DA89-42EE-A715-696E3A4873B2">SandCastle</a> and format comments accordingly.</p>
<p>Other people will probably have to extend or maintain or your unintelligible mess.  You might think it&#8217;s good for job security if you&#8217;re the only one who can understand your code.   It really isn&#8217;t.</p>
<p><strong>Read more about </strong><strong>commenting </strong><strong>code:</strong></p>
<ul>
<li><a href="http://particletree.com/features/successful-strategies-for-commenting-code/">Successful Strategies for Commenting Code</a></li>
<li><a href="http://www.literateprogramming.com/quotes_sc.html" target="_blank">Literate Programming &#8211; Source Code Comments</a></li>
</ul>
<p><strong> Follow up post:</strong></p>
<ul>
<li><a href="http://3poundmass.wordpress.com/2007/08/22/if-the-code-and-the-comments-disagree-then-both-are-probably-wrong/">If the code and the comments disagree, then both are probably wrong</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://chrisfulstow.com/coding-guidelines-commenting/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>
