<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>.NET</title>
        <link>http://blog.colinmackay.net/category/16.aspx</link>
        <description>.NET</description>
        <language>en-GB</language>
        <copyright>Colin Angus Mackay</copyright>
        <managingEditor>colin.mackay@gmail.com</managingEditor>
        <generator>Subtext Version 1.9.0.27</generator>
        <item>
            <title>Visual Studio 2008 SP1</title>
            <link>http://blog.colinmackay.net/archive/2008/08/12/3331.aspx</link>
            <description>&lt;p&gt;Visual Studio 2008 SP1 is here and can be downloaded. &lt;a href="http://blogs.msdn.com/charlie/archive/2008/08/11/released-visual-studio-service-pack-1-net-3-5-service-pack-1.aspx"&gt;Details of the downloads are here&lt;/a&gt;, and &lt;a href="http://msdn.microsoft.com/en-us/vstudio/products/cc533447.aspx"&gt;information on what SP1 brings is here&lt;/a&gt;. The big items for me are the Entity Framework and the performance improvements in LINQ.&lt;/p&gt;  &lt;p&gt;However, before you go rushing off to install SP1 there are some caveats. If you've been running the beta &lt;a href="http://blog.hinshelwood.com/"&gt;Martin Hinshelwood&lt;/a&gt; has &lt;a href="http://blog.hinshelwood.com/archive/2008/08/12/updating-to-visual-studio-2008-sp1.aspx"&gt;some advice&lt;/a&gt; and has also run in to &lt;a href="http://blog.hinshelwood.com/archive/2008/08/12/problems-with-team-explorer-after-installed-visual-studio-2008-sp1.aspx"&gt;problems running the Team Foundation Server SP1 install&lt;/a&gt; too.&lt;/p&gt;  &lt;p&gt;Once you've installed the Service Pack you might want to download the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=355c80e9-fde0-4812-98b5-8a03f5874e96&amp;amp;displaylang=en"&gt;Enhancements Training Kit&lt;/a&gt; in order to learn what's new.&lt;/p&gt;  &lt;p&gt;Finally, if you have Visual Studio 2008 Standard edition or above (not including trials) you can download the &lt;a href="http://www.axialis.com/download/iwlite.html"&gt;IconWorkshop Lite&lt;/a&gt; from &lt;a href="http://www.axialis.com"&gt;Axialsis&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8b800675-0cba-4fb5-aafc-993c8a7918a7" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Visual%20Studio" rel="tag"&gt;Visual Studio&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sp1" rel="tag"&gt;sp1&lt;/a&gt;,&lt;a href="http://technorati.com/tags/vs2008" rel="tag"&gt;vs2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Visual%20Studio%202008" rel="tag"&gt;Visual Studio 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Team%20Foundation%20Server" rel="tag"&gt;Team Foundation Server&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/3331.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/08/12/3331.aspx</guid>
            <pubDate>Tue, 12 Aug 2008 22:23:06 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/3331.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/08/12/3331.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/3331.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #8 (string performance)</title>
            <link>http://blog.colinmackay.net/archive/2008/08/04/3221.aspx</link>
            <description>&lt;p&gt;Concatenating strings in .NET can be very easy. There is the overloaded + operator that makes &lt;strong&gt;stringA + stringB + stringC&lt;/strong&gt; statements very easy to write. But, it isn't very performant. The reason is that strings are immutable, and concatenating strings in this way causes lots of short-lived objects to be created and thrown away, which in turn causes the garbage collector to run frequently.&lt;/p&gt;  &lt;p&gt;There are two better ways in .NET to concatenate strings. One is to use the &lt;strong&gt;string.Concat()&lt;/strong&gt; method. The other is to use the &lt;strong&gt;StringBuilder&lt;/strong&gt; class. They both perform better than adding strings together, but you still have to know when to use each. &lt;/p&gt;  &lt;p&gt;According to this article on "&lt;a href="http://www.codeproject.com/KB/cs/stringperf.aspx" target="_blank"&gt;Performance considerations for strings in C#&lt;/a&gt;" &lt;strong&gt;string.Concat()&lt;/strong&gt; is good up to 600 strings. But, only if you have 600 strings to concatenate in a single statement. &lt;strong&gt;StringBuilder&lt;/strong&gt; is better if you have more than 600 strings to concatenate, but you can do so over multiple statements. In reality, I think the benefits of appending strings over multiple statements with &lt;strong&gt;StringBuilder&lt;/strong&gt; will work out better even with much less than 600 strings because to get the performance out of &lt;strong&gt;string.Concat()&lt;/strong&gt; you'll have to perform some form of setup operation to line all those strings up - and that will take time.&lt;/p&gt;  &lt;p&gt;So, today's tip is don't use the plus operator to combine strings except in quick / throw-away applications. Use &lt;strong&gt;string.Concat()&lt;/strong&gt; or &lt;strong&gt;StringBuilder&lt;/strong&gt; instead.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f0529d1c-f618-4773-828b-706583c2de62" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/string" rel="tag"&gt;string&lt;/a&gt;,&lt;a href="http://technorati.com/tags/concatenation" rel="tag"&gt;concatenation&lt;/a&gt;,&lt;a href="http://technorati.com/tags/concat" rel="tag"&gt;concat&lt;/a&gt;,&lt;a href="http://technorati.com/tags/stringbuilder" rel="tag"&gt;stringbuilder&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/3221.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/08/04/3221.aspx</guid>
            <pubDate>Mon, 04 Aug 2008 12:00:54 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/3221.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/08/04/3221.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/3221.aspx</wfw:commentRss>
        </item>
        <item>
            <title>What's New in Visual Studio 2008 Service Pack 1</title>
            <link>http://blog.colinmackay.net/archive/2008/07/31/3162.aspx</link>
            <description>&lt;p&gt;Finally, Microsoft have a date for an event in Scotland. It is on 16th of October in their new offices in Waverley Gate, Edinburgh. Here are the details:&lt;/p&gt;  &lt;p&gt;[&lt;a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032384614&amp;amp;Culture=en-GB" target="_blank"&gt;Register for the event here&lt;/a&gt;]&lt;/p&gt;  &lt;p&gt;16 October 2008 13:30 - 16:15    &lt;br /&gt;Welcome Time: 13:00&lt;/p&gt;  &lt;p&gt;Microsoft Scotland   &lt;br /&gt;Waverley Gate    &lt;br /&gt;2-4 Waterloo Place     &lt;br /&gt;Edinburgh EH1 3EG&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Event Overview&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Timings&lt;/strong&gt;    &lt;br /&gt;13.00 for 13.30 Registration &lt;/p&gt;  &lt;p&gt;13.30 - 14.45 Session 1&lt;/p&gt;  &lt;p&gt;14.45 - 15.00 break &lt;/p&gt;  &lt;p&gt;15.00 -16.15 Session 2&lt;/p&gt;  &lt;p&gt;16.15 close&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Overview:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;“&lt;/em&gt;Service Pack? We’re calling it a Service Pack? Are you kidding??!?!”&lt;/p&gt;  &lt;p&gt;Visual Studio 2008 Service Pack 1 will release later in 2008 alongside .NET Framework V3.5 Service Pack 1 and, together, they represent a significant upgrade to Visual Studio 2008. There are enhancements across many areas of the .NET Framework such as data access, windows application development and web development and there are also corresponding changes in the development environment to support the new framework features.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Session 1:&lt;/b&gt;&lt;b&gt; What’s New for Web &amp;amp; Windows Development?&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Here we’ll explore the changes to web and windows development with Service Pack 1. In the web space, we’ll take a look at the new controls added to ASP.NET for easy playback of media and Silverlight content and we’ll take a good look at the new Dynamic Data framework for quick “scaffolding” of a web site. In the Windows world, we’ll look at the new capabilities of Windows Presentation Foundation V3.5 Sp1 and the new, smaller, subset of the .NET Framework in the .NET Client Profile that makes deployment of WPF applications much easier.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Session 2:&lt;/b&gt;&lt;b&gt; What’s New for Data?&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The ADO.NET team have been busy for Service Pack 1 of Visual Studio 2008. There are two major new pieces of functionality – the ADO.NET Entity Framework provides a level of abstraction over your data store with a LINQ-enabled, object-relational-mapping API. The other new piece of functionality, ADO.NET Data Services easily exposes arbitrary data over a RESTful set of web services. In this session, we’ll explore both to give you an idea of what’s happening in data access. We’ll also make a brief mention of the changes around SQL Server 2008 data types and tooling.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Speaker Biogragphy:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Mike Taulty&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Mike Taulty, Microsoft:  Mike has been in the team since 2003 and is currently looking at technologies such as Visual Studio 2008 Service Pack 1, Silverlight V2 and SQL Server 2008.  Before joining the Community team, Mike worked in Microsoft's Services group as a developer consultant focused on helping ISVs and Enterprises develop their applications.  Prior to joining Microsoft, Mike spent the previous nine years working as a software developer for a number of different software houses, end-users and consultancies, making use of various operating systems, databases and what used to be called 'middleware’.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/"&gt;&lt;b&gt;Read Mike's blog&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Eric Nelson&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;After many years of developing on UNIX/RDBMS (and being able to get mortgages) Eric joined Microsoft in 1996 as a Technical Evangelist (and stopped being able to get mortgages due to his new 'unusual job title' in the words of his bank manager). He has spent most of his time working with ISVs to help them architect solutions which make use of the latest Microsoft technologies - from the beta of ASP 1.0 through to ASP.NET, from MTS to WCF/WF and from the beta of SQL Server 6.5 through to SQL Server 2008. Along the way he has met lots of smart and fun developers - and been completely stumped by many of their questions!&lt;/p&gt;  &lt;p&gt;In July 2008 he switched role from an Application Architect to a Developer Evangelist in the Developer and Platform Group. Currently Eric’s interests include digging into LINQ to Entities, ADO.NET Data Services and switching from C# to Visual Basic development.&lt;/p&gt;  &lt;p&gt;At home, he battles rat infestations, comes second to the family dog and uses any spare moments he has after 10pm to team up and play online with and against friends - keep an eye out for 'erknel' and say 'hi'&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/ericnel/"&gt;Read Eric’s blog&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;[&lt;a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032384614&amp;amp;Culture=en-GB" target="_blank"&gt;Register for the event here&lt;/a&gt;]&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:2676a02e-b426-4088-a1b6-9f757e9ef314" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/msdn" rel="tag"&gt;msdn&lt;/a&gt;,&lt;a href="http://technorati.com/tags/microsoft" rel="tag"&gt;microsoft&lt;/a&gt;,&lt;a href="http://technorati.com/tags/visual%20studio" rel="tag"&gt;visual studio&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sp1" rel="tag"&gt;sp1&lt;/a&gt;,&lt;a href="http://technorati.com/tags/software%20development" rel="tag"&gt;software development&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/3162.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/07/31/3162.aspx</guid>
            <pubDate>Thu, 31 Jul 2008 13:18:26 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/3162.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/07/31/3162.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/3162.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Monitoring change in XML data (LINQ to XML series - Part 5)</title>
            <link>http://blog.colinmackay.net/archive/2008/07/19/2985.aspx</link>
            <description>&lt;p&gt;This is the 5th part in a series on LINQ to XML. In this instalment we will look at monitoring changes in XML data in the XML classes added to .NET 3.5.&lt;/p&gt; &lt;p&gt;The &lt;strong&gt;XObject&lt;/strong&gt; class (from which &lt;strong&gt;XElement&lt;/strong&gt; and &lt;strong&gt;XAttribute&lt;/strong&gt;, among others) contains two events that are of interest to anyone wanting to know about changes to the XML data: &lt;strong&gt;Changing&lt;/strong&gt; and &lt;strong&gt;Changed&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The &lt;strong&gt;Changing&lt;/strong&gt; event is triggered prior to a change being applied to the XML data. The &lt;strong&gt;Changed&lt;/strong&gt; event is triggered after the change has been applied.&lt;/p&gt; &lt;p&gt;An example of adding the event handler would be something like this:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;XElement &lt;/span&gt;root = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"root"&lt;/span&gt;);
root.Changed += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;XObjectChangeEventArgs&lt;/span&gt;&amp;gt;(root_Changed);&lt;/pre&gt;
&lt;p&gt;The above example will trigger for any change that happens in the node the event handler is applied to and any node downstream of it. As the example is applied to the root node this means the event will trigger for any change in the XML data.&lt;/p&gt;
&lt;p&gt;The event handler is supplied an &lt;strong&gt;XObjectChangeEventArgs&lt;/strong&gt; object which contains an &lt;strong&gt;ObjectChange&lt;/strong&gt; property. This is an &lt;strong&gt;XObjectChange&lt;/strong&gt; enum and it lets the code know what type of change happened.&lt;/p&gt;
&lt;p&gt;The sender contains the actual object in the XML data that has changed. &lt;/p&gt;
&lt;h1&gt;Adding an element&lt;/h1&gt;
&lt;p&gt;Take the following example where an element is added to the XML data.&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;XElement &lt;/span&gt;child = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ChildElement"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Original Value"&lt;/span&gt;);
root.Add(child);&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;In this case the &lt;strong&gt;ObjectChanged&lt;/strong&gt; is &lt;strong&gt;Add&lt;/strong&gt; and the sender is the &lt;strong&gt;XElement&lt;/strong&gt;: &amp;lt;ChildElement&amp;gt;Original Value&amp;lt;/ChildElement&amp;gt; &lt;/p&gt;
&lt;p&gt;A similar scenario happens when adding an attribute. However, instead of the sender being an &lt;strong&gt;XElement&lt;/strong&gt; it will be an &lt;strong&gt;XAttribute&lt;/strong&gt;.&lt;/p&gt;&lt;pre class="code"&gt;child.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XAttribute&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"TheAttribute"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Some Value"&lt;/span&gt;));&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;h1&gt;Changing an element value&lt;/h1&gt;
&lt;p&gt;If the value of the element is changed (the bit that currently says "Original Value") then we don't get one event fired. We get two events fired. For example:&lt;/p&gt;&lt;pre class="code"&gt;child.Value = &lt;span style="color: #a31515"&gt;"New Value"&lt;/span&gt;;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;The first event with &lt;strong&gt;ObjectChanged&lt;/strong&gt; set to &lt;strong&gt;Remove&lt;/strong&gt; and the sender set to "Orginal Value" (which is actually an &lt;strong&gt;XText&lt;/strong&gt; object) and the second event with the &lt;strong&gt;ObjectChanged&lt;/strong&gt; set to &lt;strong&gt;Add&lt;/strong&gt; and the sender set to "New Value" (again, this is actually an &lt;strong&gt;XText&lt;/strong&gt; object).&lt;/p&gt;
&lt;h1&gt;Changing an element name&lt;/h1&gt;
&lt;p&gt;If the name of the element is changed then the &lt;strong&gt;ObjectChanged&lt;/strong&gt; property will be set to &lt;strong&gt;Name&lt;/strong&gt; and the sender will be the &lt;strong&gt;XElement&lt;/strong&gt; that has changed. &lt;/p&gt;&lt;pre class="code"&gt;child.Name = &lt;span style="color: #a31515"&gt;"JustTheChild"&lt;/span&gt;;&lt;/pre&gt;
&lt;h1&gt;Changing an attribute name&lt;/h1&gt;
&lt;p&gt;Unlike changing an element value, when the value of an attribute changes the &lt;strong&gt;ObjectChanged&lt;/strong&gt; property will be &lt;strong&gt;Value&lt;/strong&gt; and the sender will be the &lt;strong&gt;XAttribute&lt;/strong&gt;.&lt;/p&gt;&lt;pre class="code"&gt;child.Attribute(&lt;span style="color: #a31515"&gt;"TheAttribute"&lt;/span&gt;).Value = &lt;span style="color: #a31515"&gt;"New Attribute Value"&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:43bd53b7-890e-41d1-aea0-9bf6a429e724" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/c#" rel="tag"&gt;c#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.net" rel="tag"&gt;.net&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.net%203.5" rel="tag"&gt;.net 3.5&lt;/a&gt;,&lt;a href="http://technorati.com/tags/xml" rel="tag"&gt;xml&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/2985.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/07/19/2985.aspx</guid>
            <pubDate>Sat, 19 Jul 2008 16:57:00 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/2985.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/07/19/2985.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/2985.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #4 (Connection Strings in Config files)</title>
            <link>http://blog.colinmackay.net/archive/2008/07/19/2983.aspx</link>
            <description>&lt;p&gt;From .NET 2.0 onwards a new and improved configuration management system has been put in place. You can now add a &lt;strong&gt;&amp;lt;connectionString&amp;gt;&lt;/strong&gt; element to the config file and use it to place the connection strings to the database and then retrieve then in a consistent way in your application. It supports multiple connection strings too if you need to access multiple databases.&lt;/p&gt;  &lt;p&gt;The config file looks like this:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;... &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Default&lt;/span&gt;" &lt;span style="color: red"&gt;connectionString&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Server=(local);database=MyDatabase&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;...&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/pre&gt;

&lt;p&gt;From the .NET application you can access the connection string like this:&lt;/p&gt;

&lt;pre class="code"&gt;connectionString = 
    &lt;span style="color: #2b91af"&gt;ConfigurationManager&lt;/span&gt;.ConnectionStrings[&lt;span style="color: #a31515"&gt;"Default"&lt;/span&gt;].ConnectionString;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Just remember to add a reference to System.Configuration in your project and ensure that the code file is using the System.Configuration namespace as well.&lt;/p&gt;

&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c8a83277-e372-4388-ac90-400230209d2e" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/.net" rel="tag"&gt;.net&lt;/a&gt;,&lt;a href="http://technorati.com/tags/connection%20string" rel="tag"&gt;connection string&lt;/a&gt;,&lt;a href="http://technorati.com/tags/config" rel="tag"&gt;config&lt;/a&gt;,&lt;a href="http://technorati.com/tags/configuration" rel="tag"&gt;configuration&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/2983.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/07/19/2983.aspx</guid>
            <pubDate>Sat, 19 Jul 2008 12:51:06 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/2983.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/07/19/2983.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/2983.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #2 - (Debugging into the .NET source code)</title>
            <link>http://blog.colinmackay.net/archive/2008/06/28/2674.aspx</link>
            <description>&lt;p&gt;Today's tip is that you can &lt;a href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx" target="_blank"&gt;configure Visual Studio to step-into the .NET Framework&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Here's some background: A while ago &lt;a href="http://weblogs.asp.net/scottgu" target="_blank"&gt;Scott Guthrie&lt;/a&gt; announced that the &lt;a href="http://weblogs.asp.net/scottgu/archive/2008/01/16/net-framework-library-source-code-now-available.aspx" target="_blank"&gt;source code to the .NET Framework was now available&lt;/a&gt;. And &lt;a href="http://blogs.msdn.com/sburke" target="_blank"&gt;Shawn Burke&lt;/a&gt; detailed how to actually &lt;a href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx" target="_blank"&gt;&lt;strong&gt;&lt;em&gt;configure Visual Studio 2008 to debug into the .NET Framework&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/2674.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/06/28/2674.aspx</guid>
            <pubDate>Sat, 28 Jun 2008 17:17:28 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/2674.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/06/28/2674.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/2674.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #1 (Connection Strings)</title>
            <link>http://blog.colinmackay.net/archive/2008/06/22/2610.aspx</link>
            <description>&lt;p&gt;You can add the Application Name to the connection string for SQL Server so that it becomes easier to debug problems when you use a tool like SQL Profiler as it will be much easier to identify the commands being issued by your application.&lt;/p&gt;  &lt;p&gt;For more information see &lt;a href="http://blog.benhall.me.uk/" target="_blank"&gt;Ben Hall&lt;/a&gt;'s blog: &lt;a href="http://blog.benhall.me.uk/2007/10/sql-connection-application-name.html" target="_blank"&gt;SQL Connection - Application Name&lt;/a&gt;&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b8757b3a-6c0e-4e0d-885f-1bcb0636ba9a" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/.net" rel="tag"&gt;.net&lt;/a&gt;,&lt;a href="http://technorati.com/tags/connection%20string" rel="tag"&gt;connection string&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sql%20server" rel="tag"&gt;sql server&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/2610.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/06/22/2610.aspx</guid>
            <pubDate>Sun, 22 Jun 2008 11:11:53 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/2610.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/06/22/2610.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/2610.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Navigating XML (LINQ to XML series - part 4)</title>
            <link>http://blog.colinmackay.net/archive/2008/06/22/2600.aspx</link>
            <description>&lt;p&gt;In my last few posts on LINQ to XML (&lt;a href="http://blog.colinmackay.net/archive/2008/04/08/2194.aspx" target="_blank"&gt;part 1&lt;/a&gt;, &lt;a href="http://blog.colinmackay.net/archive/2008/04/12/2203.aspx" target="_blank"&gt;part 2&lt;/a&gt; and &lt;a href="http://blog.colinmackay.net/archive/2008/05/18/2376.aspx" target="_blank"&gt;part 3&lt;/a&gt;) I've shown you a starter on navigating around XML data. In this post I'll continue to show you how to navigate through XML data by showing you how to navigate around sibling elements.&lt;/p&gt;  &lt;p&gt;First consider this code:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;XElement &lt;/span&gt;root = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"root"&lt;/span&gt;,
    &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"FirstChild"&lt;/span&gt;),
    &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"SecondChild"&lt;/span&gt;),
    &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ThirdChild"&lt;/span&gt;),
    &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"FouthChild"&lt;/span&gt;),
    &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"FifthChild"&lt;/span&gt;));&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Which produces the following XML structure:&lt;/p&gt;

&lt;p&gt;&amp;lt;root&amp;gt; 
  &lt;br /&gt;  &amp;lt;FirstChild /&amp;gt; 

  &lt;br /&gt;  &amp;lt;SecondChild /&amp;gt; 

  &lt;br /&gt;  &amp;lt;ThirdChild /&amp;gt; 

  &lt;br /&gt;  &amp;lt;FouthChild /&amp;gt; 

  &lt;br /&gt;  &amp;lt;FifthChild /&amp;gt; 

  &lt;br /&gt;&amp;lt;/root&amp;gt;&lt;/p&gt;

&lt;p&gt;We can access the &lt;strong&gt;ThirdChild&lt;/strong&gt; with this code:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;XElement &lt;/span&gt;child = root.Element(&lt;span style="color: #a31515"&gt;"ThirdChild"&lt;/span&gt;);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;From that point, we can also get access to its siblings.&lt;/p&gt;

&lt;p&gt;To access the siblings that occur before the element we have a reference to then we can use &lt;strong&gt;ElementsBeforeSelf&lt;/strong&gt;. As with &lt;strong&gt;Elements&lt;/strong&gt; this returns an &lt;strong&gt;IEnumerable&amp;lt;XElement&amp;gt;&lt;/strong&gt; object which allows us to iterate over the result, like this:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;&amp;gt; elements = child.ElementsBeforeSelf();

&lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;XElement &lt;/span&gt;element &lt;span style="color: blue"&gt;in &lt;/span&gt;elements)
    &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(element);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;The result is:&lt;/p&gt;

&lt;p&gt;&amp;lt;FirstChild /&amp;gt; 
  &lt;br /&gt;&amp;lt;SecondChild /&amp;gt;&lt;/p&gt;

&lt;p&gt;Conversely, we can get the siblings that come after the element we have a reference to with &lt;strong&gt;ElementsAfterSelf&lt;/strong&gt;. Like this:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;&amp;gt; elements = child.ElementsAfterSelf();&lt;/pre&gt;

&lt;p&gt;The result in this case will be:&lt;/p&gt;

&lt;p&gt;&amp;lt;FouthChild /&amp;gt; 
  &lt;br /&gt;&amp;lt;FifthChild /&amp;gt;&lt;/p&gt;

&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:6c154488-abff-4ac5-813b-32aa49c0a47b" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/c#" rel="tag"&gt;c#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.net" rel="tag"&gt;.net&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.net%203.5" rel="tag"&gt;.net 3.5&lt;/a&gt;,&lt;a href="http://technorati.com/tags/xml" rel="tag"&gt;xml&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/2600.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/06/22/2600.aspx</guid>
            <pubDate>Sun, 22 Jun 2008 01:43:14 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/2600.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/06/22/2600.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/2600.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Postgraduate .NET Application Development</title>
            <link>http://blog.colinmackay.net/archive/2008/06/20/2593.aspx</link>
            <description>&lt;a target="_blank" href="http://www.gcal.ac.uk/"&gt;Glasgow Caledonian University&lt;/a&gt; is currently developing a new Postgraduate course on .NET Application Development. This course will combine the expertise of their lecturers with the industry-standard Microsoft Official Curriculum. This course will offer a series of academic qualifications, starting with a Postgraduate Certificate and potentially leading on to a Postgraduate Diploma and an MSc, and will also provide preparation for Microsoft Certification in .NET specialist areas. A Postgraduate Certificate is likely to take 3 months of full-time study or 6 months part-time. A full MSc takes 1 calendar year of full-time study and 2 to 3 years part-time.&lt;br /&gt;
&lt;br /&gt;
The university has a short survey that is designed to find out how they can best deliver this course to meet the needs of potential students. They are interested in the views of potential students, employers who wish to develop staff and employers who recruit developers. If you think the course might be of interest to you, please take a moment to answer these questions.&lt;br /&gt;
&lt;br /&gt;
The survey can be found &lt;a target="_blank" href="http://www.surveymonkey.com/s.aspx?sm=Rj_2bK9gZDT1zczxje_2bIO5hA_3d_3d"&gt;here&lt;/a&gt;&lt;img src="http://blog.colinmackay.net/aggbug/2593.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/06/20/2593.aspx</guid>
            <pubDate>Fri, 20 Jun 2008 13:01:49 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/2593.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/06/20/2593.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/2593.aspx</wfw:commentRss>
        </item>
        <item>
            <title>ASP.NET / C# contract in Windsor</title>
            <link>http://blog.colinmackay.net/archive/2008/06/20/2592.aspx</link>
            <description>&lt;p&gt;There seems to be lots of opportunity for .NET developers at the moment. Another friend of mine contacted me about a job he has available for any suitable person that is interested. This time it is a contractor position based in Windsor in England and he tells me it is a great place to work.&lt;/p&gt;
&lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt;
&lt;p&gt;Skills:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;ASP.NET &lt;/li&gt;
    &lt;li&gt;C# 2.0 &lt;/li&gt;
    &lt;li&gt;SQL Server 2000/2005 &lt;/li&gt;
    &lt;li&gt;Javascript and AJAX experience &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The successful candidate will be involved in all aspects of the software lifecycle. Rates are the market rates for the south east of England. The start date is ASAP and the contract will last for 3 months initially.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;He's also told me he isn't interested in hearing from recruitment agents, so if you are one, don't annoy him by trying - you won't get anywhere.&lt;/p&gt;
&lt;p&gt;If you are initerested you can get in touch with either Daniel Molloy at &lt;a href="mailto:daniel_t_molloy@hotmail.com"&gt;daniel_t_molloy@hotmail.com&lt;/a&gt; or Ross Mardell at &lt;a href="mailto:ross.mardell@btinternet.com"&gt;ross.mardell@btinternet.com&lt;/a&gt; &lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/2592.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/06/20/2592.aspx</guid>
            <pubDate>Fri, 20 Jun 2008 11:58:26 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/2592.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/06/20/2592.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/2592.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>