<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8783816172041709062</id><updated>2011-07-08T08:43:12.626-07:00</updated><category term='NUnit'/><category term='Use Case'/><category term='LINQ'/><category term='MySQL'/><category term='Project Management'/><category term='Bug'/><category term='UML'/><category term='XML'/><category term='Stored Procedures'/><category term='Parallel Programming'/><category term='SQLServer'/><category term='CSV'/><category term='Encryption'/><category term='Tracing'/><category term='cloud'/><category term='MSBuild'/><category term='Oracle'/><category term='Azure'/><category term='XMLNS'/><category term='C#'/><category term='WF'/><category term='Reflection'/><category term='Visual Studio 2008'/><category term='WMI'/><category term='WCF'/><category term='Role Based Security'/><category term='Debugging'/><category term='Event Log'/><category term='CruiseControl'/><category term='IronRuby'/><category term='Regular Expression'/><category term='WPF'/><category term='Unit Testing'/><category term='Design Patterns'/><category term='ADO'/><category term='.NET'/><title type='text'>Design Build Release</title><subtitle type='html'>Ramblings/rants about .NET, UML and Relational Databases</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>32</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-6744741398933895727</id><published>2010-01-17T10:06:00.000-08:00</published><updated>2010-01-17T10:06:46.276-08:00</updated><title type='text'>I have moved.......</title><content type='html'>Finally got around to setting up a "proper" blog on my own hosting. &amp;nbsp;The main reason was to be able to utilise some of the code highlighting tools.&lt;br /&gt;&lt;br /&gt;My blog can now be found at&amp;nbsp;&lt;a href="http://www.iainjmitchell.com/blog"&gt;www.iainjmitchell.com/blog&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-6744741398933895727?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/6744741398933895727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=6744741398933895727' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/6744741398933895727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/6744741398933895727'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2010/01/i-have-moved.html' title='I have moved.......'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-7099524780683160599</id><published>2009-10-26T01:15:00.000-07:00</published><updated>2009-10-26T01:15:28.297-07:00</updated><title type='text'>Parallel Extensions in .NET Part 2</title><content type='html'>In the last post I covered the Co-ordination Data Structures in .NET 4.00, so now I will examine the &lt;b&gt;Task Parallel Library&lt;/b&gt; and &lt;b&gt;Parallel LINQ&lt;/b&gt; (PLINQ).&lt;br /&gt;&lt;br /&gt;As I mentioned in the last post, Mike Taulty explained that the thought behind the Parallel Extensions is to abstract the multi-processor jobs away from the concept of threads. &amp;nbsp;The Task Parallel Library contains objects that allow you to achieve this.&lt;br /&gt;&lt;br /&gt;At the heart of this is the &lt;b&gt;Task&lt;/b&gt; object which represents a unit of work to be carried out. &amp;nbsp;There is a factory version (as shown below) and a standard object version of this class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 13px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;Task myTask = Task.Factory.StartNew(() =&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//code to be carried out&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;});&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas, Arial, Helvetica, sans-serif; font-size: small;"&gt;&lt;span style="font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas, Arial, Helvetica, sans-serif; font-size: small;"&gt;&lt;span style="font-size: 12px;"&gt;myTask.Wait(); //wait for task to complete&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Which ever method you use to construct the object it is passed a predicate which contains the work to be carried out. &amp;nbsp;Tasks are atomic operations that can be carried out on any of the processors in the PC. &amp;nbsp;The Wait() command is only applicable if you need to wait for the result of the Task&lt;br /&gt;&lt;br /&gt;An interesting feature of Tasks is that a Task can start off other Tasks within them. &lt;br /&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;Task parentTask = Task.Factory.StartNew(() =&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="font-family: Consolas, Arial, Helvetica, sans-serif;"&gt;Task childTask = Task.Factory.StartNew(() =&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 13px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 13px;"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; //code to be carried out&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;});&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas, Arial, Helvetica, sans-serif; font-size: small;"&gt;&lt;span style="font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//other code to be carried out&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;&lt;span style="font-family: Consolas; font-size: 9pt;"&gt;});&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;These child classes are automatically linked to the Parent class, so that if you call Wait() on the parent class then this will wait for any child Tasks to finish. &amp;nbsp;This default behavior can be turned off (if required) in an extra parameter passed into the constructor.&lt;br /&gt;&lt;br /&gt;Another intriguing feature about these Tasks is that when an exception occurs within the main Task or one of it's children, the exception thrown is a &lt;b&gt;AggregateException&lt;/b&gt;. &amp;nbsp;This exception contains a new property called InnerExceptions that contains any exceptions that are thrown by the children. &amp;nbsp;So, if three child task are spawned and all of these throw an exception you can view all of these in this AggregateException. &amp;nbsp;Nice.&lt;br /&gt;&lt;br /&gt;Mike also introduced the Parallel static class which provides an alternative way of spawning multiple Actions. &amp;nbsp;It has handy methods such as Parallel.ForEach that allows a number of actions to be thrown a number of times. &amp;nbsp;I won't go into too much detail about this one, but if you look on the recently published MSDN for .NET 4.00 there are plenty of examples of it's use.&lt;br /&gt;&lt;br /&gt;Finally, Mike introduced use to Parallel LINQ, otherwise known as PLINQ! &amp;nbsp;This is a command that can be used on LINQ queries to make them execute across multiple processors. &amp;nbsp;It's purpose is to make LINQ queries on any large data sources more efficient.&lt;br /&gt;&lt;br /&gt;PLINQ is very easy to use, all you need to do is utilise the AsParallel() at the appropriate place in the LINQ query. &amp;nbsp;For example:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Consolas; font-size: 12px;"&gt;var results = myData.&lt;span style="color: red;"&gt;&lt;b&gt;AsParallel(&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="color: red;"&gt;)&lt;/span&gt;&lt;/b&gt;.Where(x =&amp;gt; x.Name == "World").Count();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It's that easy!&lt;br /&gt;&lt;br /&gt;That concludes my whirlwind tour of the Parallel Extensions in .NET 4.00. &amp;nbsp;There are plenty of other resources on the MSDN and various microsoft blogs on Parallel Extensions. &amp;nbsp;Here are a few:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163329.aspx"&gt;Introduction to PLINQ&lt;/a&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/concurrency/default.aspx"&gt;Microsoft Parallel Computing Center&lt;/a&gt;&lt;br /&gt;&lt;a href="http://blogs.msdn.com/pfxteam/"&gt;Microsoft Parallel Programming Team Blog&lt;/a&gt;&lt;br /&gt;&lt;a href="http://mtaulty.com/communityserver/blogs/mike_taultys_blog/default.aspx"&gt;Mike Taulty's Blog&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-7099524780683160599?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/7099524780683160599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=7099524780683160599' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/7099524780683160599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/7099524780683160599'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/10/parallel-extensions-in-net-part-2.html' title='Parallel Extensions in .NET Part 2'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-672902726032510489</id><published>2009-10-22T00:35:00.001-07:00</published><updated>2009-10-22T12:23:28.525-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Parallel Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>Parallel Extensions in .NET 4.00 Part 1</title><content type='html'>Last night I attended an &lt;span style="font-weight: bold;"&gt;NxtGen&lt;/span&gt; User Group in Manchester at which Microsoft guru &lt;b&gt;Mike Taulty&lt;/b&gt; was giving an introduction to the new parallel programming components of the .NET framework.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Whether we like it or not we, as developers, are going to have to adapt to using techniques that will run code on separate processors.  The new chips from Intel and AMD are no longer continuing to  increasing in Ghz, they are just containing more processors.  So, we need to be able to utilise this power.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The good news is that the .NET CLR and certain components, such as WCF and WF, already spread their workload across multiple processors.  But the bad news is that our own programs do not.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, how would you currently handle this?  The answer is by using a &lt;b&gt;Threads&lt;/b&gt; or a &lt;b&gt;ThreadPool&lt;/b&gt;.  But as Mike demonstrated this is quite long winded and makes the code quite difficult to read.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The idea behind the Parallel Extensions in .NET 4.00 is to abstract the concept of the work that can be carried out on multiple processors away from the underlying concept of threads.  They have split the components up into the following three categories:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Co-ordination Data Structures.&lt;/li&gt;&lt;li&gt;Task Parallel Library&lt;/li&gt;&lt;li&gt;Parallel LINQ (PLINQ)&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Lets start with the &lt;b&gt;Co-ordination Data Structures.   &lt;/b&gt;This category contains all the replacement data structures that are required to support parallel programming.  If you have ever performed any thread safe work that involves a collection, you will know that none of the collections in .NET are thread safe.  The only solution is to lock the entire collection when carrying out any work.  Which frankly is a bit rubbish.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The co-ordination data structures contain a selection of &lt;b&gt;Concurrent Collections&lt;/b&gt; to get around this issue.  These include &lt;b&gt;ConcurrentLinkedList&lt;t&gt;&lt;/t&gt;&lt;/b&gt; and &lt;b&gt;ConcurrentQueue&lt;t&gt;&lt;/t&gt;&lt;/b&gt;.  It also includes some advanced Co-ordination helpers that include a &lt;b&gt;Barrier&lt;/b&gt; (blocks work until a x number of threads reach) and a &lt;b&gt;CountdownEvent&lt;/b&gt; (a concurrent countdown that can be signalled from multiple threads).&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The last of the co-ordination data structures is the &lt;b&gt;Data Synchronizatio&lt;/b&gt;&lt;b&gt;n&lt;/b&gt; classes.  The main one of interest is the &lt;b&gt;Lazy&lt;t&gt;&lt;/t&gt;&lt;/b&gt; class.  Great name, but what does it do?  It allows you to create a thread safe Singleton class.  For example, say we have a singleton class called MyClass which has a method called MyMethod().  Initialisation of the singleton can be complex as we may have several threads entering the initialisation code.  The solution is to use the Lazy&lt;t&gt; class to wrap the class like so:&lt;/t&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: 'times new roman';"&gt;Lazy&lt;myclass&gt; myInstance = new Lazy&lt;span class="Apple-style-span" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&amp;lt;MyClass&amp;gt;&lt;span class="Apple-style-span" style="font-family: 'times new roman', Arial, Helvetica, sans-serif; font-size: medium;"&gt;()&lt;myclass&gt;;&lt;/myclass&gt;&lt;/span&gt;&lt;/span&gt;&lt;/myclass&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: 'times new roman';"&gt;myInstance.Value.MyMethod();&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This ensures that ONLY one instance of this class will exist.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the next part I will cover the Task Parallel Library.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-672902726032510489?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/672902726032510489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=672902726032510489' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/672902726032510489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/672902726032510489'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/10/parallel-extensions-in-net-400-part-1.html' title='Parallel Extensions in .NET 4.00 Part 1'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-4428979024395126906</id><published>2009-10-20T02:36:00.001-07:00</published><updated>2009-11-10T05:43:17.001-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSV'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>Creating comma separated strings with LINQ</title><content type='html'>Here is a really quick LINQ based solution to the conversion of a collection of strings into a comma separated string:&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #006600;"&gt;&lt;span style="font-family: 'times new roman';"&gt;//Prepare list&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: 'times new roman';"&gt;List&lt;string&gt; myList = new List&lt;string&gt;();&lt;/string&gt;&lt;/string&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: 'times new roman';"&gt;myList.Add(&lt;span style="color: red;"&gt;"aString"&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: 'times new roman';"&gt;myList.Add(&lt;span style="color: red;"&gt;"anotherstring"&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #006600;"&gt;&lt;span style="font-family: 'times new roman';"&gt;//Get comma separated string&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #006600;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #006600;"&gt;&lt;div&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'times new roman';"&gt;var stringBuilder = myList.Aggregate(new StringBuilder(), (builder, stringValue) =&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'times new roman';"&gt;&lt;span style="white-space: pre;"&gt;                                                        &lt;/span&gt;builder.AppendFormat((builder.Length == 0) ? &lt;span style="color: red;"&gt;"{0}"&lt;/span&gt; : &lt;span style="color: red;"&gt;", {0}&lt;/span&gt;", stringValue));&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'times new roman';"&gt;string commaString = stringBuilder.ToString();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-4428979024395126906?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/4428979024395126906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=4428979024395126906' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4428979024395126906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4428979024395126906'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/10/creating-comma-separated-strings-with.html' title='Creating comma separated strings with LINQ'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-7249466669467150917</id><published>2009-09-28T00:10:00.000-07:00</published><updated>2009-10-18T13:05:22.809-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>WCF Tracing with Activities</title><content type='html'>One of the nice features of Windows Communication Foundation (WCF) is that it can generate an excess of trace information that can help us identify issues with our services.  All you need to do is turn the tracing on through the app.config like so....&lt;div&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Courier; color:#000e5f;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;            &lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Courier; color:#000e5f;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;         &lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Courier; color:#000e5f;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;    &lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Courier; color:#000e5f;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt; &lt;div&gt;&lt;span class="Apple-style-span"   style="  color: rgb(0, 0, 102); white-space: pre-wrap; font-family:Courier, Verdana, Arial, Helvetica, sans-serif;font-size:-webkit-xxx-large;"&gt;&lt;sources&gt;&lt;listeners&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 14, 95);   white-space: normal; font-family:Courier, serif;font-size:11px;"&gt;            &lt;/span&gt;&lt;/listeners&gt;&lt;/sources&gt;&lt;/span&gt;           &lt;add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializedata="C:\log\Traces.svclog"&gt;    &lt;/add&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:Courier, Verdana, Arial, Helvetica, sans-serif;color:#000066;"&gt;&lt;span class="Apple-style-span" style="white-space: pre-wrap;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana, sans-serif; font-size: 13px; white-space: normal; line-height: 20px; "&gt;&lt;div&gt;name="System.ServiceModel"&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt; switchValue="Information"&gt;&lt;/div&gt;&lt;div&gt;&lt;listeners&gt;&lt;/listeners&gt;&lt;/div&gt;&lt;div&gt;&lt;add&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;name="traceListener"&lt;/add&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;  &lt;/span&gt;type="System.Diagnostics.XmlWriterTraceListener"&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;  &lt;/span&gt;initializeData= "c:\log\Traces.svclog" /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  color: rgb(0, 0, 102); white-space: pre-wrap; font-family:Courier, Verdana, Arial, Helvetica, sans-serif;font-size:-webkit-xxx-large;"&gt;&lt;sources&gt;&lt;listeners&gt;&lt;add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializedata="C:\log\Traces.svclog"&gt;         &lt;/add&gt;&lt;/listeners&gt;               &lt;/sources&gt; &lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;system.diagnostics&gt;&lt;/system.diagnostics&gt;&lt;/div&gt;&lt;div&gt;    &lt;sources&gt;&lt;/sources&gt;&lt;/div&gt;&lt;div&gt;Microsoft even provide a handy tool called Service Trace Viewer Tool (&lt;a href="http://msdn.microsoft.com/en-us/library/ms732023.aspx"&gt;SvcTraceViewer.exe&lt;/a&gt;) that can be used to view the trace information that WCF produces.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However, if you have ever looked at one of these traces you will have noticed that it can be difficult to sieve through and find the service call(s) that you are interested in.  It becomes especially difficult if the service calls other services.  Wading through all this tracing information is time consuming and it can be very frustrating.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Fortunately WCF provides a mechanism called &lt;b&gt;Activities&lt;/b&gt; that allow us to correlate related trace information.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Where these Activities start and stop are defined by the developer in code.  They can also be propagated across service boundaries and can also be linked together with other related activities.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, what do you need to do in order to use Activities in your tracing?  They are quite simple to use, all you need to do is assign an activity id to the correlation manager.  This is a GUID value and is assigned as follows:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;Trace.CorrelationManager.ActivityId =  Guid.NewGuid();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, all the trace messages that are fired after this will be included in this Activity.  However, in order for this to appear in the trace log we need to add &lt;b&gt;ActivityTracing&lt;/b&gt; to the &lt;b&gt;switchValu&lt;/b&gt;&lt;b&gt;e&lt;/b&gt; of the diagnostics section of the app.config.&lt;/div&gt;&lt;div&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Courier; color:#000e5f;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;             &lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Courier; color:#000e5f;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;        &lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Courier; color:#000e5f;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;    &lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Courier; color:#000e5f;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 102);  font-size:16px;"&gt;&lt;sources&gt;   &lt;listeners&gt;                &lt;add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializedata="SdrConfigExample.e2e"&gt;             &lt;/add&gt;&lt;/listeners&gt;               &lt;/sources&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  color: rgb(0, 0, 102); white-space: pre-wrap; font-family:Courier, Verdana, Arial, Helvetica, sans-serif;font-size:-webkit-xxx-large;"&gt;&lt;sources&gt;          &lt;/sources&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:Courier, Verdana, Arial, Helvetica, sans-serif;color:#000066;"&gt;&lt;span class="Apple-style-span" style="white-space: pre-wrap;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana, sans-serif; font-size: 13px; white-space: normal; line-height: 20px; "&gt;&lt;div&gt;name="System.ServiceModel"&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt; switchValue="Information &lt;b&gt;ActivityTracing&lt;/b&gt;"&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;   &lt;/span&gt;&lt;b&gt;propagateActivity="true"&lt;/b&gt;&gt;&lt;/div&gt;&lt;div&gt;&lt;listeners&gt;&lt;/listeners&gt;&lt;/div&gt;&lt;div&gt;&lt;add&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;name="traceListener"&lt;/add&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;  &lt;/span&gt;type="System.Diagnostics.XmlWriterTraceListener"&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;  &lt;/span&gt;initializeData= "c:\log\Traces.svclog" /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  color: rgb(0, 0, 102); white-space: pre-wrap; font-family:Courier, Verdana, Arial, Helvetica, sans-serif;font-size:-webkit-xxx-large;"&gt;&lt;sources&gt;  &lt;listeners&gt;                &lt;add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializedata="C:\log\Traces.svclog"&gt;             &lt;/add&gt;&lt;/listeners&gt;               &lt;/sources&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;Also, if we want the ActivityId to be passed from one service to another, we can set the &lt;b&gt;propagateActivity&lt;/b&gt; attribute to True.  This is useful if we are starting the activity in one service operations that is then calling other services operations to achieve it's goals.  With propagateActivity set to true, all of the trace information from these services for this particular call would be grouped together.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-7249466669467150917?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/7249466669467150917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=7249466669467150917' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/7249466669467150917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/7249466669467150917'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/09/wcf-tracing-with-activities.html' title='WCF Tracing with Activities'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-4507626451123430682</id><published>2009-09-16T11:16:00.000-07:00</published><updated>2009-09-17T01:18:51.123-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UML'/><title type='text'>UML Aggregation vs Composition</title><content type='html'>A colleague asked me a few weeks ago for some advice about their UML class diagram.  One of the issues they were having was deciding on whether the link between two of the classes should have a "filled-in" or "non-filled-in" diamond.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You have probably already guessed that he was really asking about whether the two classes were linked by &lt;b&gt;Aggregation&lt;/b&gt; ("non-filled-in") or &lt;b&gt;Composition&lt;/b&gt; ("filled-in").  From my experience, this is a very confusing area of UML for some developers.  I have reviewed may class diagrams where the developer seems to have just liked the look of one of the diamonds and just used it on all of their associations!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, where should these notations be used?  If you search on the internet you'll find a plethora of explanations, but I thought it might be useful to try and add a simplified explanation.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First off, this is the difficult part for developers, &lt;b&gt;Aggregation and Composition are nothing to do with code&lt;/b&gt;.  Both Aggregation and Composition are effectively talking about is one class contains another class.  So, many explanations suggest it's Aggregation if it's public property and composition if it's a private field.  But unfortunately it doesn't work like that.  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The decision on whether a relationship is a Aggregate or Composite is based on how the classes are related in the &lt;b&gt;real &lt;/b&gt;&lt;b&gt;world&lt;/b&gt;.  Take a classic UML example of a Car class.  Your car class may have a engine class, a collection of wheel classes and a fluffy dice class.  So, which of these are aggregates and which are composites?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets start with the engine class.  This is quite a vital part of the car, you couldn't imagine a car without an engine.  Likewise, the wheels are quite important too.  In fact you could say that the car is &lt;i&gt;composed of&lt;/i&gt; (among other things) an engine and wheels.  So, these relationships are examples of &lt;b&gt;Composition&lt;/b&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The remaining fluffy dice class is a bit of a looser relationship.  A cars function does not depend on the tacky fluffy dice attached to the mirror.  The car may not even have fluffy dice.  So, this demonstrates quite nicely a &lt;b&gt;Aggregation&lt;/b&gt; relationship.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, our resulting class diagram looks something like this...&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5axvRZmG1Vg/SrHwhjAoVEI/AAAAAAAAACk/-LtrJ2Ud8uU/s1600-h/ClassDiagram.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 214px;" src="http://2.bp.blogspot.com/_5axvRZmG1Vg/SrHwhjAoVEI/AAAAAAAAACk/-LtrJ2Ud8uU/s400/ClassDiagram.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5382347488808686658" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-4507626451123430682?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/4507626451123430682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=4507626451123430682' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4507626451123430682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4507626451123430682'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/09/uml-aggregation-vs-composition.html' title='UML Aggregation vs Composition'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_5axvRZmG1Vg/SrHwhjAoVEI/AAAAAAAAACk/-LtrJ2Ud8uU/s72-c/ClassDiagram.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-5137285157356247029</id><published>2009-05-11T06:11:00.000-07:00</published><updated>2009-05-11T06:36:02.992-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle'/><title type='text'>Oracle vs .NET int</title><content type='html'>One of the problems of using .NET with Oracle is the type conversion of integers through the ODAC component.  Basically, the problem comes about because the ODAC component has no idea which .NET type to use when returning a value in a NUMBER field.... so it panics and just tends to return everything as a double (remember that the NUMBER field can hold decimal values!).&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Oracle have also provided the INTEGER data type, which is really just a short-cut to get a NUMBER(32) field.  The best solution I can find to this is to define any columns that are being mapped to a .NET int as &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;NUMBER(9, 0)&lt;/span&gt;.   This will always ensure that the field will hold data that is compatible with being held in a .NET int.  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-5137285157356247029?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/5137285157356247029/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=5137285157356247029' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/5137285157356247029'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/5137285157356247029'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/05/oracle-vs-net-int.html' title='Oracle vs .NET int'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-5671139650864640901</id><published>2009-03-25T21:00:00.000-07:00</published><updated>2009-03-30T00:33:27.543-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Design Patterns'/><category scheme='http://www.blogger.com/atom/ns#' term='cloud'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Azure'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>Devweek Day Two</title><content type='html'>&lt;h4&gt;Session 1 - Building applications in the ‘cloud’ with Azure services.&lt;/h4&gt;Started the day back with Christian &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Weyer&lt;/span&gt; for another of his amusing style of talks.  This time he was introducing how Azure can be used to build applications in the ‘cloud’.  The overall impression that I am getting of Azure is that it is a work in-progress.  Christian demonstrated this by showing a technology uptake diagram, which well and truly placed ‘cloud’ computing in the emerging technologies section.&lt;br /&gt;&lt;br /&gt;Azure is organised into two types of service, web and worker services.  The idea is that the services can be &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;up scaled&lt;/span&gt; so that the capacity of the application can be increased.  For example, if you have a particularly popular web service that starts getting hit by thousands or millions of users you can log into Azure and increase the number of service instances to cover this demand.&lt;br /&gt;&lt;br /&gt;Underlying the two core service types is the service bus.  This is basically an enterprise service bus in the ‘cloud’.  It allows the management and routing of service interactions with services held within the cloud and locally.&lt;br /&gt;&lt;br /&gt;Christian also briefly showed the Azure &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;workflow&lt;/span&gt; services.  These will allow processes or interactions between services to be mapped out visually.  Azure &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;workflow's&lt;/span&gt; are not based on standard Windows &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;Workflow&lt;/span&gt; (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;WF&lt;/span&gt;).  They only have a relatively small sub-set of activities that are very ‘cloud’ specific (e.g. connect to cloud service).  Although &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;WF&lt;/span&gt; seems to be a major part of Microsoft's ‘cloud’ master-plan, they are still far from stable.&lt;br /&gt;&lt;h4&gt;Session 2 - The Patterns Dartboard.&lt;/h4&gt;For some light entertainment prior to lunch I decided to attend this talk on design patterns.  The premise of this talk was that a dart was to be thrown at a ‘dartboard’ of design patterns.  Whichever pattern the dart hit one of the presenters, Kevin Jones and Andy &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;Clymery&lt;/span&gt;, would present to the group in no more than 15 minutes.&lt;br /&gt;&lt;br /&gt;During the next hour and a half they covered the Decorator, Factory, Active Record, State and Mode View Controller (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;MVC&lt;/span&gt;) design patterns.  Of these I had particular interest in the Active Record presentation.  Actually a first I had no idea what this design pattern was!  Then as the presentation moved onwards I realised this is another name for what used to be my favorite design pattern, the &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_9"&gt;Persistence&lt;/span&gt; pattern.&lt;br /&gt;&lt;br /&gt;I have to say, I very rarely use Active Record (AKA &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_10"&gt;Persistence&lt;/span&gt;) anymore, Though it is quite well suited to a small reliable system.  I don’t know a great deal about Ruby on Rails but apparently this is the design pattern that it utilises.&lt;br /&gt;&lt;br /&gt;For those not familiar with Active Record is that the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;class&lt;/span&gt; should contain the business logic and the code necessary to persist the object in the data store (usually some kind of database).  Their interpretation of Active Record suggested that all ‘read’ actions should be  static methods and all ‘write’ actions should be instance methods.  The example &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;class&lt;/span&gt; below demonstrates this:&lt;br /&gt;&lt;br /&gt;public class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;MyClass&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;private int Id;&lt;br /&gt;&lt;br /&gt;public static &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;MyClass&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;GetMyClass&lt;/span&gt;(int &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;classId&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;   //database select code and return new object with data...     }&lt;br /&gt;&lt;br /&gt;public void Save()&lt;br /&gt;{&lt;br /&gt;   //if object does not have ID then INSERT to database else UPDATE...     } }&lt;br /&gt;&lt;br /&gt;I must admit that in my my years of employing this design pattern it never occurred to me to implement the loading functions as static members.&lt;br /&gt;&lt;h4&gt;Session 3 - &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;WCF&lt;/span&gt; Security Architecture and Best Practice.&lt;/h4&gt;This was one of the ‘must-see’ sessions of the week for me, particularly due to recent issues that I have encountered with security within my &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;WCF&lt;/span&gt; applications.  Like many features within &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;WCF&lt;/span&gt; this can be a confusing area as there is SO much that is configurable.&lt;br /&gt;&lt;br /&gt;Dominick &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;Baier&lt;/span&gt; ran this session which went into incredible detail about the security options that are available within &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;WCF&lt;/span&gt;.  I can’t say that I managed to find an exact solution to my particular problem, but I found it a great grounding in the elements of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;WCF&lt;/span&gt; security (it’s all about the Binding!).   Plus, I now have his email address - beware Dominick!&lt;br /&gt;&lt;br /&gt;As I’m still taking in this wealth of knowledge it is difficult for me to expand any further at the moment.&lt;br /&gt;&lt;h4&gt;Session 4 - Visual Studio 2008 &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;IDE&lt;/span&gt; Tricks and Tips.&lt;/h4&gt;Can I first say that I attended this session purely as my brain &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_24"&gt;couldn't&lt;/span&gt; take any more heavy talks on the second day.  The &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;WCF&lt;/span&gt; security session well and truly finished me off!&lt;br /&gt;&lt;br /&gt;Though I have to say that I will be using many of the short-cuts that were introduced in this session.  &lt;a href="http://www.codinghorror.com/blog/files/Visual%20Studio%20.NET%202005%20Keyboard%20Shortcuts.htm"&gt;Here&lt;/a&gt; is a website that summarises the standard shortcuts in Visual Studio.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-5671139650864640901?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/5671139650864640901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=5671139650864640901' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/5671139650864640901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/5671139650864640901'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/03/devweek-day-two.html' title='Devweek Day Two'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-7751247321823443100</id><published>2009-03-24T20:00:00.000-07:00</published><updated>2009-03-27T06:27:07.283-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cloud'/><category scheme='http://www.blogger.com/atom/ns#' term='IronRuby'/><category scheme='http://www.blogger.com/atom/ns#' term='Azure'/><category scheme='http://www.blogger.com/atom/ns#' term='WF'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>Devweek Day One</title><content type='html'>Here is a quick summary of the sessions that I attended on the first day of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;DevWeek&lt;/span&gt; in London.&lt;br /&gt;&lt;h4&gt;Session 1 - Keynote: Cloud computing - a new era of software development.&lt;/h4&gt;At the opening of this session &lt;a href="http://www.pluralsight.com/community/blogs/aaron/default.aspx"&gt;Aaron &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Skonnard&lt;/span&gt;&lt;/a&gt; asked who knew anything about Cloud computing.  I &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;didn&lt;/span&gt;’t raise my hand as I still feel that I don’t know that much, though in retrospect I could have done as this session covered pretty much what I already knew!&lt;br /&gt;&lt;br /&gt;Over the hour and a half he covered the different types of “clouds” in distributed computing, starting from basic network design then moving on to Software as a service providers an finally the new online cloud computing providers such as Google, Amazon and briefly mentioning Microsoft’s Azure.&lt;br /&gt;&lt;h4&gt;Session 2 - A Beginners guide to Windows &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;Workflow&lt;/span&gt; (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;WF&lt;/span&gt;).&lt;/h4&gt;I’&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;ve&lt;/span&gt; had a few attempts at using &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;WF&lt;/span&gt; but thought I’d attend this session to see if I’d missed anything.  It turns out I had!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetconsult.co.uk/weblog2/"&gt;Richard &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;Blewett&lt;/span&gt;&lt;/a&gt; ran an interesting session with plenty of code samples taking the audience through the basic &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;WF&lt;/span&gt; components.  For those who have never seen &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;WF&lt;/span&gt; it provides a graphical tool to arrange “activities” which interact with your underlying code.  It allows you to design the business process through a diagram rather than inside lines of code.&lt;br /&gt;&lt;br /&gt;One of the nice features of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;WF&lt;/span&gt; is that you can attach &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;workflow&lt;/span&gt; services to the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;runtime&lt;/span&gt; that the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;workflow&lt;/span&gt;’s can then interact with (don’t confuse these with &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;WCF&lt;/span&gt; or Web services).  If these services are defined from interfaces of abstract classes then it allows a dependency injection mechanism into the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;workflow&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Richard showed an example where a custom activity talking to a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;workflow&lt;/span&gt; service which showed a textual output.  The custom activity retrieved an abstract class called &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;MyOutput&lt;/span&gt;, it had one abstract method called &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;WriteOutput&lt;/span&gt; which required a message as a parameter.  He had written two child classes of the abstract class, one of which wrote the message to the Console and one which wrote the message to a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;MessageBox&lt;/span&gt;.Show().  He then demonstrated that switching between adding each of these to the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;workflow&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;runtime&lt;/span&gt; services resulted in the change of behavior when the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;workflow&lt;/span&gt; containing the custom activity was run.&lt;br /&gt;&lt;br /&gt;He also spent some time talking about how custom activities can &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_23"&gt;utilise&lt;/span&gt; the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;WorkflowQueue&lt;/span&gt; service to put items that are needed for interaction outside the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;workflow&lt;/span&gt;.&lt;br /&gt;&lt;h4&gt;Session 3 - &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;IronRuby&lt;/span&gt;.&lt;/h4&gt;This session was one of my high points of the day.  I've heard much said about Ruby on Rails and was intrigued by &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_27"&gt;Microsoft's&lt;/span&gt; .NET compatible interpretation.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.pluralsight.com/community/blogs/tewald/default.aspx"&gt;Tim &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;Ewald&lt;/span&gt;&lt;/a&gt; went through the main language differences between &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;IronRuby&lt;/span&gt; and the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;CLR&lt;/span&gt; languages.  One of the interesting examples was this:&lt;br /&gt;&lt;br /&gt;1.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;upto&lt;/span&gt;(10) { |n| put n}&lt;br /&gt;&lt;br /&gt;Which is the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;equivilant&lt;/span&gt; of this in C#....&lt;br /&gt;&lt;br /&gt;for(int i; i &lt;- 10; i++) {     Console.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;WriteLine&lt;/span&gt;(i); }  .. pretty good stuff!  &lt;h4&gt;Session 4 - &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_34"&gt;WCF&lt;/span&gt; Tips and Tricks.&lt;/h4&gt;&lt;a href="http://blogs.thinktecture.com/"&gt;Christian &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_35"&gt;Weyer&lt;/span&gt;&lt;/a&gt; took this session which looked at how &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_36"&gt;WCF&lt;/span&gt; should be used in the real world.  His ideas seem to match many conclusions that we have drawn, such as self-hosting is the way to go at the moment and providing some mechanism for locally initialising services is a good idea (has he been spying on our system? :))&lt;br /&gt;&lt;br /&gt;One interesting point that he raised was that you should check the state of the service connection before attempting to close it.  I certainly &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_37"&gt;hadn't&lt;/span&gt; thought about this in our client code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-7751247321823443100?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/7751247321823443100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=7751247321823443100' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/7751247321823443100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/7751247321823443100'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/03/devweek-day-one.html' title='Devweek Day One'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-3170489997718831219</id><published>2009-03-05T03:51:00.000-08:00</published><updated>2009-03-05T05:34:10.468-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>WCF Exceptions and Faults</title><content type='html'>In Windows Communication Foundation (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;WCF&lt;/span&gt;) exceptions thrown from services have to be converted into &lt;span style="font-weight: bold;"&gt;Faults&lt;/span&gt; - which are basically cross domain friendly exceptions.  Custom faults can be created and are just &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;declared&lt;/span&gt; using the&lt;span style="font-weight: bold;"&gt; [&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;DataContract&lt;/span&gt;]&lt;/span&gt; attribute.  The example below shows the declaration of a simple Fault.&lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 280px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;[&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;DataContract&lt;/span&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;    public class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;MyFault&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        [&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;DataMember&lt;/span&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        public string Message { get; set; }      &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        public &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;PasswordFault&lt;/span&gt;()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        public &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;PasswordFault&lt;/span&gt;(string message)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;            this.Message = message;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;    }&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;To generate a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;WCF&lt;/span&gt; fault you have to use the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;FaultException&lt;/span&gt;&lt;t&gt; class.   The example below shows how we could raise the fault declared in the previous example.&lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 280px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;public class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;myService&lt;/span&gt;: &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;IMyContract&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt; public void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;MyMethod&lt;/span&gt;&lt;/span&gt;()&lt;br /&gt; {&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;       ......&lt;br /&gt;    {&lt;br /&gt;    catch (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;myException&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;exc&lt;/span&gt;)&lt;br /&gt;    {&lt;br /&gt;      &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;MyFault&lt;/span&gt; = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;MyFault&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;exc&lt;/span&gt;.Message);&lt;br /&gt;      throw new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;FaultException&lt;/span&gt;&lt;myfault&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;MyFault&lt;/span&gt;, "Failed to run &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;MyMethod&lt;/span&gt;");&lt;br /&gt;    }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt; One other important part of setting up faults in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;WCF&lt;/span&gt; is that the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;OperationalContract&lt;/span&gt; of the method raising the fault needs to define the the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;FaultContracts&lt;/span&gt; that the method can raise.  For example we might define the &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_24"&gt;service&lt;/span&gt; contract of our service to be as follows:&lt;br /&gt;&lt;div face="consolas,'Courier New',courier,monospace" size="8pt" style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 280px; line-height: 12pt; background-color: rgb(244, 244, 244);"&gt;   &lt;pre face="consolas,'Courier New',courier,monospace" size="8pt" style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;[&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;ServiceContract&lt;/span&gt;]&lt;br /&gt;public interface &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;IMyContract&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt; [&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;OperationContract&lt;/span&gt;]&lt;br /&gt; [&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;FaultContract&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;typeof&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;AuthenticationFault&lt;/span&gt;))]&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;  void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;MyMethod&lt;/span&gt;&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  The &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;FaultContract&lt;/span&gt; attribute is telling &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;WCF&lt;/span&gt; which faults can be expected.  If a fault is thrown that is not defined here, the client will just get an &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_34"&gt;ambiguous&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_35"&gt;FaultException&lt;/span&gt; raised and be unable to access the extra data defined in the Fault.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Alternative Fault Handling Techniques&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Recently, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_36"&gt;during&lt;/span&gt; the development of quite a large &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_37"&gt;SOA&lt;/span&gt; based system I noticed that Faults that are raised by sub-services were not being raised correctly through the next service.  The only way to ensure that these faults were &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_38"&gt;received&lt;/span&gt; by the client was to recapture the fault (as a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_39"&gt;FaultException&lt;/span&gt;&lt;myfault&gt;() ) and &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_40"&gt;re throw&lt;/span&gt; them!&lt;br /&gt;&lt;br /&gt;After a bit of investigation and a very helpful reply to a post on the &lt;a href="http://social.msdn.microsoft.com/forums/en-US/wcf/threads/"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_41"&gt;MSDN&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_42"&gt;WCF&lt;/span&gt; forum&lt;/a&gt; I was pointed in the direction of &lt;a href="http://www.codeproject.com/KB/WCF/WCFErrorHandling.aspx?display=Print"&gt;this example&lt;/a&gt; of using the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_43"&gt;IErrorHandler&lt;/span&gt; interface to add custom error handlers to the individual channel dispatcher.  I'm not going to go into any great amount of detail about this, but I strongly recommend reading the article.  It gives you a much more elegant way of handling exception to fault conversions in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_44"&gt;WCF&lt;/span&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-3170489997718831219?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/3170489997718831219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=3170489997718831219' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/3170489997718831219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/3170489997718831219'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/03/wcf-exceptions-and-faults.html' title='WCF Exceptions and Faults'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-5687502745095954571</id><published>2009-03-04T01:57:00.000-08:00</published><updated>2009-03-04T02:11:07.085-08:00</updated><title type='text'>Safari 4</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5axvRZmG1Vg/Sa5R3zUJP1I/AAAAAAAAABY/UeKIRBNNmQg/s1600-h/whatsnew-hero-20090217.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 576px; height: 242px;" src="http://1.bp.blogspot.com/_5axvRZmG1Vg/Sa5R3zUJP1I/AAAAAAAAABY/UeKIRBNNmQg/s320/whatsnew-hero-20090217.png" alt="" id="BLOGGER_PHOTO_ID_5309271029825748818" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;A beta of Safari 4 for Mac and PC was released last week, go &lt;a href="http://www.apple.com/safari/"&gt;here&lt;/a&gt; for download.&lt;br /&gt;It features some rather nice eye candy - such as a "cover flow" browsing history and a rather nice favorite site window (see screen shots above).&lt;br /&gt;&lt;br /&gt;I'm sure many web developers will be shuddering at the thought of yet another browser to support, but it does bring with it some new web technologies (such as &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;CSS&lt;/span&gt; 3 and HTML 5).  It also provides some rather nice looking developer tools, see &lt;a href="http://www.apple.com/safari/features.html"&gt;here&lt;/a&gt; for full feature list.&lt;br /&gt;&lt;br /&gt;I tried using Safari 4 for a couple of days on my work PC.  It seemed to be &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;noticeably&lt;/span&gt; faster than other browsers, though it did seem to hang a bit when adding new tabs - this might be because it was set to always start new tabs on the favorite site window.  I think if the hanging issues could be resolved it could give &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;Firefox&lt;/span&gt; some competition.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-5687502745095954571?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/5687502745095954571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=5687502745095954571' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/5687502745095954571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/5687502745095954571'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/03/safari-4.html' title='Safari 4'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_5axvRZmG1Vg/Sa5R3zUJP1I/AAAAAAAAABY/UeKIRBNNmQg/s72-c/whatsnew-hero-20090217.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-5551850240459626999</id><published>2009-02-25T08:23:00.000-08:00</published><updated>2009-02-25T08:42:37.561-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle'/><title type='text'>Oracle XmlType and ODAC .NET provider</title><content type='html'>I have been having some issues today with a method that inserted &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Xml&lt;/span&gt; into an &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;XmlType&lt;/span&gt; field in an Oracle database.  It had been working fine, but recently the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;Xml&lt;/span&gt; had grew in size considerably.  I was now getting the following Oracle error returned from the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;ODAC&lt;/span&gt; component:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial; font-size: 13px; line-height: 18px; "&gt;&lt;b&gt;ORA-01461: can bind a LONG value only for insert into a LONG column&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The Insert Query I was running looked a bit like this....&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;INSERT INTO &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;myTable&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;anId&lt;/span&gt;, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;myXmlField&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;VALUES&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;(:&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;anId&lt;/span&gt;, :&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;myXmlField&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When I ran the query I had two parameters, the second (:&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;myXmlField&lt;/span&gt;) was an &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;Xml&lt;/span&gt; string.  It was this that caused the issue.  Thanks to &lt;a href="http://www.makiwa.com/index.php/2006/07/16/ora-01461-when-inserting-into-an-oracle-xmltype-column/"&gt;this&lt;/a&gt; post by Stuart Campbell I found out that in order to pass a long string value to an &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;XmlType&lt;/span&gt; field you must: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) Set the parameter type of the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;xml&lt;/span&gt; parameter (:&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;myXmlField&lt;/span&gt;) to &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;Clob&lt;/span&gt;; &lt;/div&gt;&lt;div&gt;2) Use the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;XmlType&lt;/span&gt;() call in the query:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'times new roman'; "&gt;INSERT INTO &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;myTable&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;anId&lt;/span&gt;, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;myXmlField&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;VALUES&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;(:&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;anId&lt;/span&gt;, &lt;b&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;XmlType&lt;/span&gt;(&lt;/b&gt;:&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;myXmlField&lt;/span&gt;&lt;b&gt;)&lt;/b&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This did resolve the issue, but in the end I ended up changing the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;XmlType&lt;/span&gt; field into a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;Clob&lt;/span&gt;! This is because 1)I didn't need to &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;xPath&lt;/span&gt; the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;Xml&lt;/span&gt; in the database and 2) I couldn't use &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;XmlType&lt;/span&gt; implementations in our &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;SqlServer&lt;/span&gt; data access layer as we have to support earlier versions of this database.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-5551850240459626999?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/5551850240459626999/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=5551850240459626999' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/5551850240459626999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/5551850240459626999'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/02/oracle-xmltype-and-odac-net-provider.html' title='Oracle XmlType and ODAC .NET provider'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-546340479383529266</id><published>2009-02-24T01:54:00.000-08:00</published><updated>2009-02-24T01:59:44.644-08:00</updated><title type='text'>For those in the North West.....</title><content type='html'>There is a free MSDN event on at the Lowry in Manchester on Thurday afternoon (26-Feb-2009).&lt;br /&gt;The event is covering WPF and Silverlight 2.&lt;br /&gt;&lt;br /&gt;See &lt;a href="http://msdn.microsoft.com/en-gb/bb905504.aspx"&gt;here&lt;/a&gt; for further details and registration.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-546340479383529266?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/546340479383529266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=546340479383529266' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/546340479383529266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/546340479383529266'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/02/for-those-in-north-west.html' title='For those in the North West.....'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-8314701243464647005</id><published>2009-02-23T15:37:00.000-08:00</published><updated>2009-02-23T07:37:53.704-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Regular Expression'/><category scheme='http://www.blogger.com/atom/ns#' term='Encryption'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><title type='text'>Custom authentication</title><content type='html'>&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;Occasionally&lt;/span&gt; you may have to develop a system that, rather then relying on an existing security system (e.g. active directory, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;novell&lt;/span&gt;),  requires you to write a custom authentication system.&lt;br /&gt;&lt;br /&gt;Usually, in such systems the user data and passwords are stored in a table in the database.  These records can then be queried to determine whether the user requesting access has the correct password.&lt;br /&gt;&lt;br /&gt;Okay, this is simple enough... but storing a users password in a table is not particularly great.  A hacker or other unauthorised user might get access to the table and thus be able to log onto our system as anyone they choose!&lt;br /&gt;&lt;br /&gt;It is better practice to encrypt the password before storing it in the database.  The software will have to retrieve and decrypt this value before the users password entry can be validated.&lt;br /&gt;&lt;br /&gt;Even if encryption is used, the account could still be open to attack as Users might choose an obvious password.  Fortunately, extra precautions can be added to the security system to help further protect against unauthorised access.  These are:&lt;br /&gt;&lt;br /&gt;1) &lt;span style="font-weight: bold;"&gt;Adding rules for password format&lt;/span&gt; - &lt;a href="http://en.wikipedia.org/wiki/Regular_expression"&gt;Regular expressions&lt;/a&gt; can be used to ensure when a user sets their password it adheres to certain standards (e.g. contains 1+ numbers, is a certain length).&lt;br /&gt;&lt;br /&gt;2) &lt;span style="font-weight: bold;"&gt;Password attempts&lt;/span&gt; - Implement code to lock the account if the password is entered incorrectly over a certain number of times.  To save on hassle for the system administrators you might want to consider just locking the account for a set period (e.g. 2 hours).&lt;br /&gt;&lt;br /&gt;3) &lt;span style="font-weight: bold;"&gt;Encrypt with Salt values&lt;/span&gt; - A &lt;a href="http://en.wikipedia.org/wiki/Salt_%28cryptography%29"&gt;salt&lt;/a&gt; value is a value that is added to password prior to encryption to make the &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_2"&gt;encryption&lt;/span&gt; more difficult to crack for hackers using &lt;a href="http://en.wikipedia.org/wiki/Dictionary_attack"&gt;dictionary attacks&lt;/a&gt;.  I would strongly recommend using salt values if you are using encryption.&lt;br /&gt;&lt;br /&gt;In .NET salt values can be generated by using a class such as &lt;a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.rngcryptoserviceprovider.aspx"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;RNGCryptoServiceProvider&lt;/span&gt;&lt;/a&gt;.  &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_4"&gt;The&lt;/span&gt; code below shows a static method I use to generate salt values.&lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 280px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;/// &lt;summary&gt;&lt;/summary&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;///&lt;/span&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;Generate a random salt value&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;/// &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;br /&gt;public static string &lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;GenerateSalt&lt;/span&gt;()&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;  &lt;span style="color: rgb(51, 153, 153);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;RNGCryptoServiceProvider&lt;/span&gt;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;rng&lt;/span&gt;&lt;/span&gt; = new &lt;span style="color: rgb(51, 153, 153);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;RNGCryptoServiceProvider&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;();&lt;/span&gt;&lt;br /&gt;  byte&lt;span style="color: rgb(0, 0, 0);"&gt;[] &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;randomNumber&lt;/span&gt; = &lt;/span&gt;new byte&lt;span style="color: rgb(0, 0, 0);"&gt;[16];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;rng&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;GetBytes&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;randomNumber&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;  return &lt;span style="color: rgb(51, 153, 153);"&gt;Convert&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;ToBase&lt;/span&gt;64String(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;randomNumber&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The encryption algorithms in .NET (such as the &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_15"&gt;preferred&lt;/span&gt; &lt;a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;RijndaelManaged&lt;/span&gt;&lt;/a&gt; class) allow you to set the salt value when encrypting and decrypting values.&lt;br /&gt;&lt;br /&gt;It is important to remember that when you use a salt value that this will also need to be stored somewhere, so that it can be retrieved by the code when it needs to decrypt.  Salt values should NEVER be stored in code as a hacker could use a &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_17"&gt;disassembler&lt;/span&gt; on the assembly and discover the value.&lt;br /&gt;&lt;br /&gt;I always dynamically create a new salt value &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_18"&gt;every time&lt;/span&gt; a users password is changed.  This value&lt;br /&gt;is then stored in a &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_19"&gt;separate&lt;/span&gt; table in the database, linked to the record by the user table primary key.  This can then be easily retrieved when the code needs to decrypt the data.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I hope I've managed to cover the main points of creating a custom authentication system.  It'll will be interesting to see what the next generation of security systems in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;WCF&lt;/span&gt; 4.0 and &lt;a href="http://www.microsoft.com/azure/default.mspx"&gt;Azure&lt;/a&gt; will bring.  I'm hoping that there will be considerable improvements so that developers will not have to keep reinventing the wheel with their own authentication methods.  I am attending &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;DevWeek&lt;/span&gt; next month in London, so I'll blog/twitter my discoveries....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-8314701243464647005?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/8314701243464647005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=8314701243464647005' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/8314701243464647005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/8314701243464647005'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/01/custom-authentication.html' title='Custom authentication'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-4888600629113824521</id><published>2009-01-27T02:07:00.000-08:00</published><updated>2009-01-27T02:21:16.742-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Stored Procedures'/><category scheme='http://www.blogger.com/atom/ns#' term='SQLServer'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle'/><title type='text'>Stored procedure maintenance</title><content type='html'>One of the nice features of Oracle stored procedures, functions and packages is that you can create or recreate the database side code in the same statement.  The advantage of this is that during upgrades/patches you can run ALL database code scripts again, which ensures nothing is missed - and also that the changes you have made haven't caused breaking changes in another procedure!&lt;br /&gt;&lt;br /&gt;For example, the following will create or replace the following security package header..&lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 280px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;CREATE OR REPLACE PACKAGE PKG_SECURITY&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;AUTHID&lt;/span&gt; DEFINER&lt;br /&gt;AS&lt;br /&gt;/*  ------------------------------------------------------&lt;br /&gt;    Adds authentication for specified user to system    &lt;br /&gt;    ------------------------------------------------------ */&lt;br /&gt;PROCEDURE &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;proc&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;AddUserAuthentication&lt;/span&gt;(&lt;br /&gt;  &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;userId&lt;/span&gt;                IN &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;USERSECURITY&lt;/span&gt;.USER_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;FK&lt;/span&gt;%TYPE,&lt;br /&gt;  &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;encryptedPassword&lt;/span&gt;     IN &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;USERSECURITY&lt;/span&gt;.PASSWORD%TYPE,&lt;br /&gt;  &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;saltValue&lt;/span&gt;             IN &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;USERSALT&lt;/span&gt;.SALT%TYPE,&lt;br /&gt;  &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;auditUserId&lt;/span&gt;           IN &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;USERSECURITY&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;AUDITUSERID&lt;/span&gt;%TYPE);&lt;br /&gt;END;&lt;br /&gt;/&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;My recent digging around has revealed that you can also mimic this CREATE or REPLACE &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_13"&gt;functionality&lt;/span&gt; in MySQL and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;Sql&lt;/span&gt; Server.&lt;br /&gt;&lt;br /&gt;In MySQL you can call the DROP PROCEDURE IF EXISTS method....&lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 280px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;DROP PROCEDURE IF EXISTS &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;premierenvoy&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;proc&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;AddUserAuthentication&lt;/span&gt;;&lt;br /&gt;CREATE&lt;br /&gt;DEFINER = CURRENT_USER&lt;br /&gt;PROCEDURE &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;proc&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;AddUserAuthentication&lt;/span&gt;(&lt;br /&gt;............&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;...and in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;Sql&lt;/span&gt; Server you can use the OBJECT_ID function and check whether the returning value is not null to determine whether to drop the procedure.&lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 280px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;IF OBJECT_ID('&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;proc&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;AddUserAuthentication&lt;/span&gt;') IS NOT NULL&lt;br /&gt;DROP PROCEDURE &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;proc&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;AddUserAuthentication&lt;/span&gt;;&lt;br /&gt;GO&lt;br /&gt;CREATE PROCEDURE &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;proc&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;AddUserAuthentication&lt;/span&gt;(&lt;br /&gt;............&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-4888600629113824521?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/4888600629113824521/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=4888600629113824521' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4888600629113824521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4888600629113824521'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/01/stored-procedure-maintance.html' title='Stored procedure maintenance'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-479245468754824852</id><published>2009-01-08T00:26:00.000-08:00</published><updated>2009-01-08T00:35:11.453-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><title type='text'>Using Data Grids in WPF</title><content type='html'>One of the biggest &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;omissions&lt;/span&gt; from the .NET 3.5. &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;WPF&lt;/span&gt; control library is a Data Grid.  There are many 3rd party &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_2"&gt;implementations&lt;/span&gt; for sale of free (just do a Google search on &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;WPF&lt;/span&gt; and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;DataGrid&lt;/span&gt;).  However, it is also possible to use the standard Windows forms &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;DataGrid&lt;/span&gt; within your &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;WPF&lt;/span&gt; form.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetheaven.com/UploadFile/rahul4_saxena/DataGridInXAML05152007064009AM/DataGridInXAML.aspx"&gt;This&lt;/a&gt; excellent &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_7"&gt;article&lt;/span&gt; by &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;Rahul&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;Saxen&lt;/span&gt; explains how this can be achieved.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-479245468754824852?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/479245468754824852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=479245468754824852' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/479245468754824852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/479245468754824852'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2009/01/using-data-grids-in-wpf.html' title='Using Data Grids in WPF'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-3072925036601367997</id><published>2008-11-20T07:53:00.000-08:00</published><updated>2008-11-20T07:59:26.054-08:00</updated><title type='text'>MySQL Triggers</title><content type='html'>My recent 'baptism of fire' with MySQL triggers has revealed a couple of differences with their cousins in the SQL Server and Oracle domain.&lt;br /&gt;&lt;br /&gt;1) You need seperate triggers for UPDATE, INSERT and DELETE.  Oracle and SQL Server will let you combine these into one trigger.&lt;br /&gt;&lt;br /&gt;2) You cannot create triggers dynamically using a Procedure.  The Execute command in the stored procedures works fine when creating a table, but try creating a Trigger.  The parser throws an error stating that you can not run these types of commands.&lt;br /&gt;&lt;br /&gt;The real problem for me has been 2).  I often rely on writing procedures to apply auditing to a table (composed of audit table and trigger to insert the data from the main table into the audit table).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-3072925036601367997?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/3072925036601367997/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=3072925036601367997' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/3072925036601367997'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/3072925036601367997'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/11/mysql-triggers.html' title='MySQL Triggers'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-6412033100955914778</id><published>2008-11-06T06:27:00.000-08:00</published><updated>2008-11-06T07:00:54.894-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQLServer'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle'/><title type='text'>Creating copies of tables in Oracle, SqlServer and MySQL</title><content type='html'>As the sub-title of my blog &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;suggests&lt;/span&gt;, I am from an Oracle background.  But I also have dealings with &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;SQL&lt;/span&gt; Server and MySQL databases.  In fact the latest project I'm working on is going to have to work with all three databases!&lt;br /&gt;&lt;br /&gt;One issue I have encountered recently is how to create copies of tables in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;SQL&lt;/span&gt; Server and MySQL.  In Oracle you would use the AS keyword in the CREATE table statement and select from the table that is being copied.  For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="font-weight: bold;"&gt;CREATE&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;TABLE &lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;myCopyTable&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;  &lt;span style="font-weight: bold;"&gt;SELECT&lt;/span&gt; * &lt;span style="font-weight: bold;"&gt;FROM&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;myOriginalTable&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can add a WHERE clause to restrict the records that are included in the copy.  Making this WHERE clause into a condition that is not achievable (such as WHERE 1 =2) will result in a copy of the table without the data.  &lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Note: &lt;/span&gt;This copy does not include any indexes/constraints on the original table.&lt;br /&gt;&lt;br /&gt;In MySQL it is similar but you do not need the AS keyword.  For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;CREATE&lt;/span&gt; &lt;span style="font-family:times new roman;"&gt;&lt;span style="font-weight: bold;"&gt;TABLE &lt;/span&gt;&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;myCopyTable&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SELECT&lt;/span&gt; * &lt;span style="font-weight: bold;"&gt;FROM&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;myOriginalTable&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;Alternatively you can actually create an exact copy including all constraints and indexes.  This is achieved by using the LIKE keyword.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;CREATE TABLE &lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;myCopyTable&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;LIKE &lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;myOriginalTable&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Note:&lt;/span&gt; This won't take the data across, you would have to insert that afterwards&lt;br /&gt; (e.g. &lt;span style="font-style: italic;"&gt;INSERT INTO myCopyTable SELECT * FROM myOriginalTable;&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;Finally, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;SQL&lt;/span&gt; Server... which wins the prize for the strangest &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_10"&gt;implementation&lt;/span&gt;.  You actually use a SELECT command to create your new table :o&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SELECT&lt;/span&gt; *&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;INTO&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;myCopyTable&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FROM &lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;myOriginalTable&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;I really don't like the way this is &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_13"&gt;implemented&lt;/span&gt; as there is no mention of a table being created in the SQL statement. Even though this is what the user is trying to achieve.&lt;br /&gt;Anyhow, no point complaining at least they provided a way of copying a table :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-6412033100955914778?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/6412033100955914778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=6412033100955914778' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/6412033100955914778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/6412033100955914778'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/11/creating-copies-of-tables-in-oracle.html' title='Creating copies of tables in Oracle, SqlServer and MySQL'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-486798641055905103</id><published>2008-10-31T07:48:00.000-07:00</published><updated>2008-11-18T02:27:35.491-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Oracle'/><title type='text'>Auto numbering fields in Oracle</title><content type='html'>Auto numbering fields often come up in debates between fans of Oracle and SqlServer.  The SqlServer devotee will argue that their database has the advantage as it provides easy to use auto numbering fields.  The Oracle believers come-back will undoubtedly be... "ah but you can use Triggers".&lt;br /&gt;&lt;br /&gt;So how do you?  Luckily, I've just been implimenting this very thing in Oracle, so I thought I'd share with you my solution.&lt;br /&gt;&lt;br /&gt;First off, let me define a table that the solution will be based upon....&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;CREATE TABLE &lt;/span&gt;TestTable&lt;br /&gt;( TestTable_PK &lt;span style="font-weight: bold;"&gt;NUMBER&lt;/span&gt;(10) &lt;span style="font-weight: bold;"&gt;NOT NULL PRIMARY KEY&lt;/span&gt;,&lt;br /&gt;AValue &lt;span style="font-weight: bold;"&gt;VARCHAR2&lt;/span&gt;(10)&lt;br /&gt;&lt;br /&gt;The first column (TestTable_PK) is the one which we want to populate with an auto numbering value.&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;# Applying auto-numbering:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The auto-numbering solution is made up of two components:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The &lt;span style="font-weight: bold;"&gt;Sequence&lt;/span&gt; - to provide the auto numbering value.&lt;/li&gt;&lt;li&gt;The &lt;span style="font-weight: bold;"&gt;Trigger&lt;/span&gt; - to add the auto numbering value to the row.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;So, let us start by defining the Sequence....&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;CREATE SEQUENCE&lt;/span&gt; TestTable_SEQ&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;MINVALUE&lt;/span&gt; 0&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;MAXVALUE&lt;/span&gt; 999999999999999999999999999&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;START WITH&lt;/span&gt; 1&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;INCREMENT BY&lt;/span&gt; 1;&lt;br /&gt;&lt;br /&gt;...and then we can define our auto numbering Trigger.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;CREATE TRIGGER&lt;/span&gt; TestTable_TRG&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;BEFORE INSERT ON&lt;/span&gt; TestTable&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FOR EACH ROW&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;  SELECT&lt;/span&gt;  TestTable_SEQ.nextval &lt;span style="font-weight: bold;"&gt;INTO&lt;/span&gt; :new.TestTable_PK &lt;span style="font-weight: bold;"&gt;FROM&lt;/span&gt; dual;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;END&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;The Trigger has to occur before the insert otherwise the Primary Key unique constraint will throw an error.  It also has to fire for each row because if we are inserting multiple records we want a different sequence value for each.  The :new variable in the trigger references the row contents that is inserted to the table after the Trigger has fired.&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;# Returning the auto-numbering value:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Okay, so now we have out auto numbering working, how can we insert data and return the auto-generated number?  This can be achieved by using the &lt;span style="font-weight: bold;"&gt;RETURNING&lt;/span&gt; keyword on the &lt;span style="font-weight: bold;"&gt;INSERT&lt;/span&gt; statement.  For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;INSERT INTO&lt;/span&gt; TestTable&lt;br /&gt;(aValue)&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;VALUES&lt;/span&gt;&lt;br /&gt;('Some Data')&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;RETURNING&lt;/span&gt; TestTable_PK &lt;span style="font-weight: bold;"&gt;INTO&lt;/span&gt; :value;&lt;br /&gt;&lt;br /&gt;The :value is a variable that can be queried in the client to get the returned field.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;font-size:130%;" &gt;# Generic Solution:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the code block below I have included the code to PL/SQL package that I have written to automatically add auto-numbering to a specified table.  I do make an assumption in my code that the column that is being used as a auto numbering field is called &lt;table_name&gt;_PK.  You could write to query the data dictionary views to return the actual Primary Key, but this could cause problems if the Primary Key includes more than one field.&lt;br /&gt;&lt;br /&gt;Hope you find it useful.&lt;br /&gt;&lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 500px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;CREATE OR REPLACE PACKAGE PKG_Utilities&lt;br /&gt;AUTHID DEFINER&lt;br /&gt;AS&lt;br /&gt;/*  ------------------------------------------------------&lt;br /&gt;Add Auto numbering to the Primary Key of the table.&lt;br /&gt;------------------------------------------------------ */&lt;br /&gt;PROCEDURE proc_AddAutoNumbering(&lt;br /&gt;tableName IN VARCHAR2);&lt;br /&gt;END;&lt;br /&gt;/&lt;br /&gt;&lt;br /&gt;CREATE OR REPLACE PACKAGE BODY PKG_Utilities&lt;br /&gt;AS&lt;br /&gt;/* ***********************************************************************&lt;br /&gt;FORWARD DECLARATION OF PRIVATE METHODS&lt;br /&gt;*********************************************************************** */&lt;br /&gt;FUNCTION func_AddAutoNumberingSequence(&lt;br /&gt;tableName IN VARCHAR2) RETURN VARCHAR2;&lt;br /&gt;PROCEDURE proc_AddAutoNumberingTrigger(&lt;br /&gt;tableName IN VARCHAR2,&lt;br /&gt;sequenceName IN VARCHAR2);&lt;br /&gt;FUNCTION func_ObjectExists(&lt;br /&gt;/*  Does the object exist in the current schema? */&lt;br /&gt;objectName IN VARCHAR2,&lt;br /&gt;objectType IN VARCHAR2)&lt;br /&gt;RETURN BOOLEAN;&lt;br /&gt;FUNCTION func_GetSafeIdentifier(&lt;br /&gt;/*  Returns an identifier under 26 characters in length&lt;br /&gt;that can be concatenated with a prefix such as _TRG and&lt;br /&gt;still be under the 30 character limit for Oracle object names */&lt;br /&gt;objectName IN VARCHAR2)&lt;br /&gt;RETURN VARCHAR2;&lt;br /&gt;/* ***********************************************************************&lt;br /&gt;PUBLIC METHODS&lt;br /&gt;*********************************************************************** */&lt;br /&gt;PROCEDURE proc_AddAutoNumbering(&lt;br /&gt;tableName IN VARCHAR2)&lt;br /&gt;IS&lt;br /&gt;sequenceName VARCHAR2(200);&lt;br /&gt;BEGIN&lt;br /&gt;sequenceName:= func_AddAutoNumberingSequence(tableName);&lt;br /&gt;proc_AddAutoNumberingTrigger(tableName, sequenceName);&lt;br /&gt;END;&lt;br /&gt;/* ***********************************************************************&lt;br /&gt;PRIVATE METHODS&lt;br /&gt;*********************************************************************** */&lt;br /&gt;FUNCTION func_AddAutoNumberingSequence(&lt;br /&gt;tableName IN VARCHAR2)&lt;br /&gt;RETURN VARCHAR2&lt;br /&gt;IS&lt;br /&gt;execute_sql  VARCHAR2(1000);&lt;br /&gt;sequenceName VARCHAR2(30);&lt;br /&gt;BEGIN&lt;br /&gt;sequenceName:= func_GetSafeIdentifier(tableName) || '_SEQ';&lt;br /&gt;IF (NOT(func_ObjectExists(sequenceName, 'SEQUENCE'))) THEN&lt;br /&gt;execute_sql:= 'CREATE SEQUENCE PremierEnvoy.' || sequenceName || chr(10) ||&lt;br /&gt;              'MINVALUE 0 ' || chr(10) ||&lt;br /&gt;              'MAXVALUE 999999999999999999999999999' || chr(10) ||&lt;br /&gt;              'START WITH 1' || chr(10) ||&lt;br /&gt;              'INCREMENT BY 1';&lt;br /&gt;EXECUTE IMMEDIATE execute_sql;&lt;br /&gt;END IF;&lt;br /&gt;RETURN sequencename;&lt;br /&gt;EXCEPTION&lt;br /&gt;WHEN others THEN&lt;br /&gt;raise_application_error(-20001, 'Failed to Add Sequence - ' || execute_sql);&lt;br /&gt;END;&lt;br /&gt;&lt;br /&gt;PROCEDURE proc_AddAutoNumberingTrigger(&lt;br /&gt;tableName IN VARCHAR2,&lt;br /&gt;sequenceName IN VARCHAR2)&lt;br /&gt;IS&lt;br /&gt;triggerName VARCHAR2(30):= func_GetSafeIdentifier(tableName) || '_TRG';&lt;br /&gt;execute_sql VARCHAR2(2000):=&lt;br /&gt;'CREATE TRIGGER PremierEnvoy.' || triggerName || chr(10) ||&lt;br /&gt;'BEFORE INSERT ON PremierEnvoy.' || tableName || chr(10) ||&lt;br /&gt;'FOR EACH ROW ' || chr(10) ||&lt;br /&gt;'BEGIN ' || chr(10) ||&lt;br /&gt;'  SELECT ' || sequenceName || '.nextval' || chr(10) ||&lt;br /&gt;'  INTO :new.' || tableName || '_PK FROM dual;' ||  chr(10) ||&lt;br /&gt;'END;';&lt;br /&gt;BEGIN&lt;br /&gt;IF (NOT(func_ObjectExists(triggerName, 'TRIGGER'))) THEN&lt;br /&gt;EXECUTE IMMEDIATE execute_sql;&lt;br /&gt;END IF;&lt;br /&gt;END;&lt;br /&gt;&lt;br /&gt;FUNCTION func_ObjectExists(&lt;br /&gt;objectName IN VARCHAR2,&lt;br /&gt;objectType IN VARCHAR2)&lt;br /&gt;RETURN BOOLEAN IS&lt;br /&gt;objectCount NUMBER;&lt;br /&gt;BEGIN&lt;br /&gt;SELECT count(object_name)&lt;br /&gt;INTO objectCount&lt;br /&gt;FROM user_objects&lt;br /&gt;WHERE UPPER(object_name) = UPPER(objectName)&lt;br /&gt; AND UPPER(object_type) = UPPER(objectType);&lt;br /&gt;RETURN (objectCount &gt; 0);&lt;br /&gt;END;&lt;br /&gt;&lt;br /&gt;FUNCTION func_GetSafeIdentifier(&lt;br /&gt;   objectName IN VARCHAR2)&lt;br /&gt; RETURN VARCHAR2&lt;br /&gt; IS &lt;br /&gt; BEGIN&lt;br /&gt;   IF (LENGTH(objectName) &lt; 25) THEN&lt;br /&gt;     RETURN objectName;&lt;br /&gt;   ELSE&lt;br /&gt;     RETURN SUBSTR(objectName, 0, 25);&lt;br /&gt;   END IF;&lt;br /&gt; END;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/table_name&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-486798641055905103?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/486798641055905103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=486798641055905103' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/486798641055905103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/486798641055905103'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/10/auto-numbering-fields-in-oracle.html' title='Auto numbering fields in Oracle'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-6578219941025574939</id><published>2008-10-23T08:28:00.000-07:00</published><updated>2008-10-23T08:59:27.635-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Reflection'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>Deep Copies in .NET</title><content type='html'>A problem that I often have when writing WCF services is that WCF complains when you try to send an Object that has been cast to an ancestor over the wire (as a DataContract).  WCF responds by getting confused as to what type of object it is returning.&lt;br /&gt;&lt;br /&gt;The only solutions is to create a new instance of the parent class and copy all the fields/properties from the child.  This is effectively making a &lt;a href="http://en.wikipedia.org/wiki/Object_copy"&gt;Deep Copy&lt;/a&gt; of the object... so it got me thinking about how I could impliment a Deep Copying function in .NET.&lt;br /&gt;&lt;br /&gt;My Solution has been implimented as an &lt;a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx"&gt;Exension Method&lt;/a&gt; as I want it to be called on a class, but I don't want to have a distant ancestor to all my classes that contains this method.  The method itself uses reflection to work out the fields and property values that it needs to copy across.&lt;br /&gt;&lt;br /&gt;The code is as follows:&lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 280px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public static object &lt;span style="color: rgb(0, 0, 0);"&gt;GetDeepCopy&lt;t&gt;(&lt;/span&gt;this &lt;span style="color: rgb(0, 0, 0);"&gt;T originalObject&lt;/span&gt;, &lt;span style="color: rgb(0, 204, 204);"&gt;Type&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;newObjectType)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;  object &lt;span style="color: rgb(0, 0, 0);"&gt;newObject&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt; Activator&lt;span style="color: rgb(0, 0, 0);"&gt;.CreateInstance(newObjectType);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  //copy fields&lt;br /&gt;  &lt;span style="color: rgb(0, 204, 204);"&gt;FieldInfo[]&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;fields = newObject.GetType().GetFields();&lt;/span&gt;&lt;br /&gt;  int &lt;span style="color: rgb(0, 0, 0);"&gt;i = 0;&lt;/span&gt;&lt;br /&gt;  foreach &lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 204, 204);"&gt;FieldInfo&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;field&lt;/span&gt; in &lt;span style="color: rgb(0, 0, 0);"&gt;fields)&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;       fields[i].SetValue(newObject, field.GetValue(originalObject));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;       i++;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;   }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  //copy properties&lt;br /&gt;  &lt;span style="color: rgb(0, 204, 204);"&gt;PropertyInfo[]&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;properties = newObject.GetType().GetProperties();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;   i = 0;&lt;/span&gt;&lt;br /&gt;  foreach &lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;PropertyInfo &lt;span style="color: rgb(0, 0, 0);"&gt;property&lt;/span&gt; in &lt;span style="color: rgb(0, 0, 0);"&gt;properties)&lt;/span&gt;&lt;br /&gt;  {&lt;br /&gt;      &lt;span style="color: rgb(0, 0, 0);"&gt;properties[i].SetValue(newObject, property.GetValue(originalObject, null), null);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;       i++;&lt;/span&gt;&lt;br /&gt;  }&lt;br /&gt;  return &lt;span style="color: rgb(0, 0, 0);"&gt;newObject;&lt;/span&gt;&lt;br /&gt;}&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;This class can be used against any classes if it's namespace is included in the code in which you are using the objects.  Here is an example of it in use:&lt;br /&gt;&lt;br /&gt;ChildClass one = new ChildClass()&lt;br /&gt; {&lt;br /&gt;      Active = true,&lt;br /&gt;      Address = "HHWWH",&lt;br /&gt;      testone = Testy.two,&lt;br /&gt;      otherstuff = "sdsadasd"&lt;br /&gt; };&lt;br /&gt; &lt;br /&gt; ParentClass two = (ParentClass)one.GetDeepCopy(typeof(ParentClass));&lt;br /&gt;&lt;br /&gt;As you can see, the routine requires that a type is passed in and also the returned value must be cast to the same type.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-6578219941025574939?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/6578219941025574939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=6578219941025574939' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/6578219941025574939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/6578219941025574939'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/10/deep-copies-in-net.html' title='Deep Copies in .NET'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-7726370109035167018</id><published>2008-10-13T03:23:00.000-07:00</published><updated>2008-10-13T03:33:52.425-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Checking if a string is empty</title><content type='html'>In C# there are a variety of ways of checking if a string is empty.  The main methods I have seen people use are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;myString&lt;/span&gt; == String.Empty;&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;myString&lt;/span&gt; == "";&lt;/li&gt;&lt;li&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;myString&lt;/span&gt;.Length == 0;&lt;/li&gt;&lt;/ol&gt;So, which is the best one to use?  &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;FxCop&lt;/span&gt; provides the answer in it's performance rule &lt;a href="http://msdn.microsoft.com/en-gb/ms182279.aspx"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;TestForEmptyStringsUsingStringLength&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;As the name probably gives away, the most efficient method is &lt;span style="font-weight: bold; font-style: italic;"&gt;3. &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;myString&lt;/span&gt;.Length == 0&lt;/span&gt;&lt;span style="font-style: italic;"&gt;;&lt;/span&gt;  Or alternatively we can use the &lt;span style="font-weight: bold; font-style: italic;"&gt;String.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;IsNullOrEmpty&lt;/span&gt;()&lt;/span&gt; method to test that the string isn't null at the same time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-7726370109035167018?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/7726370109035167018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=7726370109035167018' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/7726370109035167018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/7726370109035167018'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/10/checking-if-string-is-empty.html' title='Checking if a string is empty'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-4148208367348674020</id><published>2008-10-09T06:31:00.000-07:00</published><updated>2008-10-09T07:21:10.734-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Role Based Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle'/><title type='text'>.NET Role Based Security</title><content type='html'>I am currently looking at &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;implimenting&lt;/span&gt; Users and Security in a new product.  Ideally I want to use a Role Based Security (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;RBS&lt;/span&gt;) system, so I've been revisiting the role Based security classes and interfaces that exist in the .NET framework.  I have to say that I believe that Microsoft have got this area of the .NET framework wrong *.   This is why...&lt;br /&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;RBS&lt;/span&gt; has three components:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The Users&lt;/li&gt;&lt;li&gt;The Roles&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The Permissions (AKA rights)&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;Users are assigned to 0..* roles and roles contain 0..* permissions.&lt;br /&gt;Permissions can be assigned to many roles.&lt;br /&gt;(see the diagram on the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;wikipedia&lt;/span&gt; page &lt;a href="http://en.wikipedia.org/wiki/RBAC"&gt;here&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;In the .NET framework Microsoft have developed classes such as &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;WindowsPrincipal&lt;/span&gt; and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;GenericPrinciple&lt;/span&gt; to test whether a User is a member of a particular Role.&lt;br /&gt;For example:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;GenericIdentity&lt;/span&gt; identity = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;GenericIdentity&lt;/span&gt;("&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;IMitchell&lt;/span&gt;");&lt;br /&gt;string[] roles = new string[] { "Administrator", "Manager" };&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;GenericPrincipal&lt;/span&gt; principle = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;GenericPrincipal&lt;/span&gt;(identity, roles);&lt;br /&gt;&lt;br /&gt;//Imperative Security Check&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;bool&lt;/span&gt; able = principle.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;IsInRole&lt;/span&gt;("Administrator");&lt;br /&gt;&lt;br /&gt;//Declarative Security Check&lt;br /&gt;[&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;PrincipalPermission&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;SecurityAction.Demand&lt;/span&gt;, Role="Manager")]&lt;br /&gt;private void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;DoSomething&lt;/span&gt;()&lt;br /&gt;{&lt;br /&gt;....&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;I don't think this is right... I don't think that roles should play a part in the programming.  Really you should be checking if the user has the permission to do a certain task.  Whether they have that &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;aquired&lt;/span&gt; that right from being in role &lt;span style="font-style: italic;"&gt;"Administrator"&lt;/span&gt; or role&lt;span style="font-style: italic;"&gt; "Manager"&lt;/span&gt; is irrelevant to the program.&lt;br /&gt;&lt;br /&gt;Also, by including security checking based on role names you are imposing these on the end users... who would be far better off defining their own roles to reflect their own organisational structure.&lt;br /&gt;&lt;br /&gt;A good example of a good &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;RBS&lt;/span&gt; system in operation is in the Oracle Database.  In the database various permissions to database objects are automatically &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_18"&gt;defined&lt;/span&gt; by the database (e.g. select from &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;aTable&lt;/span&gt;, execute stored procedure).  Oracle leaves it to the Database Administrator to define their own roles and users and build the association.  So one can assume that underneath the hood Oracle is actually checking whether the User has the permission rather than being concerned with how they got it!&lt;br /&gt;&lt;br /&gt;I'm not going to be overly critical though, as Microsoft have provided the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;IPrinciple&lt;/span&gt; and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;IIdentity&lt;/span&gt; interfaces to help us build custom &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_22"&gt;implementations&lt;/span&gt; of the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;RBS&lt;/span&gt;.  I will be using these to develop a permission based checking security system.  If I managed to develop this in a non-product specific way I'll post it on this blog in the near future.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;* &lt;/span&gt;&lt;span style="font-style: italic;"&gt;This of course is only my &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_24"&gt;opinion&lt;/span&gt; ;)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-4148208367348674020?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/4148208367348674020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=4148208367348674020' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4148208367348674020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4148208367348674020'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/10/net-role-based-security.html' title='.NET Role Based Security'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-2720258984587474512</id><published>2008-09-26T02:17:00.000-07:00</published><updated>2008-09-26T02:55:28.549-07:00</updated><title type='text'>Why FxCop is essential</title><content type='html'>As part of my recent work configuring an automated build server I was asked to ensure that &lt;a href="http://www.blogger.com/SqlCommand%20command%20=%20new%20SqlCommand%28sqlCommand,%20_connection%29;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;FxCop&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; was run as part of the process.  I have had, in previous jobs, experience of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;FxCop&lt;/span&gt;&lt;/span&gt; in it's integrated form (as the code analysis tool in Visual Studio Team System).  But I have to say it was something that was never used that often and I have to admit most of us ignored what it was saying.&lt;br /&gt;&lt;br /&gt;We decided to aim to reduce the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;FxCop&lt;/span&gt;&lt;/span&gt; errors in our build report to zero.  It seemed a little harsh at first, but I think this is going to seriously help our coding standards.&lt;br /&gt;&lt;br /&gt;First off (for all you doubters out there), &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;FxCop&lt;/span&gt;&lt;/span&gt; is not always right.  There are occasions that it is unhappy about something that cannot be changed.  For example, we use &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;NUnit&lt;/span&gt;&lt;/span&gt; for our unit tests and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;FxCop&lt;/span&gt;&lt;/span&gt; loves to complain that many of the test methods should be static methods (as they don't reference anything in the class).  However, if you convert these to static methods &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;NUnit&lt;/span&gt;&lt;/span&gt; fails.&lt;br /&gt;&lt;br /&gt;&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_7"&gt;Luckily&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;FxCop&lt;/span&gt;&lt;/span&gt; provides a means to ignore methods that are breaking rules.  This is how you do it:&lt;br /&gt;&lt;ol&gt;&lt;li&gt; In Visual Studio, open up the .NET project &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_9"&gt;properties&lt;/span&gt; and select the Build tab.  In the &lt;span style="font-weight: bold;"&gt;conditional compilation symbols&lt;/span&gt; box add &lt;span style="font-weight: bold;"&gt;CODE_ANALYSIS&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;Add &lt;span style="font-weight: bold;"&gt;using System.Diagnostics.CodeAnalysis;&lt;/span&gt; to the code file.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Above the method that is giving the error add a &lt;span style="font-weight: bold;"&gt;[&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;SuppressMessage&lt;/span&gt;&lt;/span&gt;]&lt;/span&gt; attribute, referencing the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;FxCop&lt;/span&gt;&lt;/span&gt; rule assembly, The rule Id/Name and a Justification (this is optional but I strongly recommend this is used so that future developers will know why this isn't being checked).  Below is an example from one of my &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;NUnit&lt;/span&gt;&lt;/span&gt; test files to avoid the previously mentioned static problem:&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;        [&lt;span style="color: rgb(51, 204, 255);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;SuppressMessage&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;(&lt;span style="color: rgb(255, 0, 0);"&gt;"Microsoft.Performance"&lt;/span&gt;, &lt;span style="color: rgb(255, 0, 0);"&gt;"CA1822:&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;MarkMembersAsStatic&lt;/span&gt;&lt;/span&gt;"&lt;/span&gt;,&lt;br /&gt;           Justification = &lt;span style="color: rgb(255, 0, 0);"&gt;"&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;FXcop&lt;/span&gt;&lt;/span&gt; doesn't realise that this &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;Nunit&lt;/span&gt;&lt;/span&gt; test method cannot be static"&lt;/span&gt;)]&lt;br /&gt;&lt;br /&gt;You can also turn off particular rules from the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;FxCop&lt;/span&gt; configuration tool, or as a command line argument (e.g.  /&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;ruleid&lt;/span&gt;:-Microsoft.Design#CA1014  &lt;span style="font-style: italic;"&gt;The minus before the rule name indicates that this rule should not be used&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;This suppression is useful, but don't just suppress every warning and error.  This will lose any benefit of running &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;FxCop&lt;/span&gt;&lt;/span&gt;!&lt;br /&gt;&lt;br /&gt;So, what sort of genuine errors has &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;FxCop&lt;/span&gt; found?  Many are small things like picking up incorrect casing in names of methods, parameters and other class members.  These may seem insignificant to the project as a whole but they are key to future developers understanding the project.&lt;br /&gt;&lt;br /&gt;Some of the more interesting errors that &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;FxCop&lt;/span&gt; has returned have involved Globalisation issues.  I have to admit that this is something that is often missed in project development.  For example a recent &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;FxCop&lt;/span&gt; report noticed that I created a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;DataTable&lt;/span&gt; without &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_22"&gt;specifying&lt;/span&gt; a Locale... so what you might say.  However, if this isn't set to &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;CultureInfo&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;InvariantCulture&lt;/span&gt; it could effect any sorting performed on this &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;DataTable&lt;/span&gt; by users in different locations!&lt;br /&gt;&lt;br /&gt;In conclusion, we should be using code analysis tools like &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;FxCop&lt;/span&gt;.  We may think that our code is perfect, but as the analysis proves, it often is not.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-2720258984587474512?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/2720258984587474512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=2720258984587474512' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/2720258984587474512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/2720258984587474512'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/09/why-fxcop-is-essential.html' title='Why FxCop is essential'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-2095743637080549980</id><published>2008-09-12T03:54:00.000-07:00</published><updated>2008-09-12T04:03:32.381-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CruiseControl'/><category scheme='http://www.blogger.com/atom/ns#' term='MSBuild'/><title type='text'>Cryptographic failure while signing assembly (MSBuild / CruiseControl .NET)</title><content type='html'>I came across an interesting error through &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;CruiseControl&lt;/span&gt;, when I updated one of our assemblies to be signed with a Strong Named Key File.  The &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;CruiseControl&lt;/span&gt; build report stated:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 69, 0); font-family: verdana; font-size: 9px; white-space: pre; "&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;errorCS&lt;/span&gt;1548: Cryptographic failure while signing assembly 'c:\&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;myCheckoutArea&lt;/span&gt;\&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;myProject&lt;/span&gt;\obj\Debug\&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;myProject&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;dll&lt;/span&gt;' -- 'Access is denied. '&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After much searching on the &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_7"&gt;Internet&lt;/span&gt; and several red herrings later I finally stumbled across a solution.  Simply change the permissions on the &lt;span class="Apple-style-span" style="color: rgb(8, 8, 8); font-family: Verdana; font-size: 13px; "&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;%&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;SystemDrive&lt;/span&gt;%\Documents and Settings\All Users\Application Data\Microsoft\&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;Crypto&lt;/span&gt;\&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;RSA&lt;/span&gt;\&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;MachineKeys&lt;/span&gt;&lt;/span&gt; so that the user has full access to this folder.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-2095743637080549980?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/2095743637080549980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=2095743637080549980' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/2095743637080549980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/2095743637080549980'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/09/cryptographic-failure-while-signing.html' title='Cryptographic failure while signing assembly (MSBuild / CruiseControl .NET)'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-4029560042197404839</id><published>2008-09-03T06:04:00.000-07:00</published><updated>2008-09-03T06:28:15.119-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unit Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='NUnit'/><title type='text'>NUnit through Visual Studio</title><content type='html'>As you may know Visual Studio (VS) has quite nice integration with MSTest projects.  It has a test list editor and view that allow you to see the tests in the solution and choose which to run.  If any fail you can debug through the tests using the VS debugger.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However, as you may have gathered from previous posts we are using NUnit, basically beacause we don't want to buy an extra VS licence for our automated build machine (yes, thanks Microsoft for not including MSTest in the .NET SDK!).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thankfully, I have disovered a nice add in for VS called &lt;a href="http://www.codeplex.com/NUnitForVS"&gt;NUnitForVS&lt;/a&gt;.  This allows NUnit tests to be run and debugged in the same way that MSTest projects are.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Through my install I did discover a couple of issues:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) You have to manually edit the NUnit Test projects &lt;span class="Apple-style-span" style="font-style: italic; "&gt;.csproj&lt;/span&gt; file to &lt;span class="Apple-style-span" style="font-family: 'Segoe UI'; "&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;contain a ProjectTypeGuid &lt;/span&gt;&lt;/span&gt;&lt;projecttypeguids&gt;&lt;span class="Apple-style-span"  style="font-family:georgia;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;element.  The one specified on the linked website did not work with VS 2008, so I checked one of my MSTest projects and found the following value which did work...&lt;/span&gt;&lt;/span&gt;&lt;/projecttypeguids&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;projecttypeguids&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'times new roman'; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&amp;lsaquo;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: georgia; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;ProjectTypeGuid&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Georgia; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'times new roman'; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&amp;rsaquo;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Georgia; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'times new roman'; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt; &lt;/span&gt;{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'times new roman'; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;&amp;lsaquo;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: georgia; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;ProjectTypeGuid&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Georgia; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'times new roman'; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;&amp;rsaquo;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/projecttypeguids&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;2) My Unit Tests didn't appear at first in the Test View.  You have to rebuild the software for it to recalculate the list.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hint - For ease, I have added a new template project for NUnit tests.   This was created as a Class Library, but I have manually edited the &lt;span class="Apple-style-span" style="font-style: italic; "&gt;.csproj&lt;/span&gt; file to contain the &lt;projecttypeguids&gt;&lt;span class="Apple-style-span" style="font-family: georgia; "&gt;ProjectTypeGuid &lt;span class="Apple-style-span" style="font-family: Georgia; "&gt;element I mentioned above. &lt;/span&gt;&lt;/span&gt;&lt;/projecttypeguids&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-4029560042197404839?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/4029560042197404839/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=4029560042197404839' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4029560042197404839'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4029560042197404839'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/09/nunit-through-visual-studio.html' title='NUnit through Visual Studio'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-4554541197685566948</id><published>2008-08-29T04:03:00.000-07:00</published><updated>2008-08-29T04:25:08.990-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unit Testing'/><title type='text'>NUnit missing assembly reference error</title><content type='html'>&lt;div  style="color:orangered;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Recently I have been getting a few errors running &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Nunit&lt;/span&gt; on our automatic build server.  &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Nunit&lt;/span&gt; is being called through an &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;MSBuild&lt;/span&gt; file, which is being called by &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;CruiseControl&lt;/span&gt;.NET.&lt;/span&gt;  &lt;span style="color: rgb(0, 0, 0);"&gt;The &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;CruiseControl&lt;/span&gt; build log has been recording the error messages below:&lt;/span&gt;&lt;/div&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;    &lt;div  style="color:orangered;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;EventLogListenerTest&lt;/span&gt;.cs (6,7): &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;errorCS&lt;/span&gt;0246: The type or &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;namespace&lt;/span&gt; name '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;NUnit&lt;/span&gt;' could not be found (are you missing a using directive or an assembly reference?)&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;EventLogListenerTest&lt;/span&gt;.cs (18,10): &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;errorCS&lt;/span&gt;0246: The type or &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;namespace&lt;/span&gt; name '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;TestFixtureSetUp&lt;/span&gt;' could not be found (are you missing a using directive or an assembly reference?)&lt;/div&gt; &lt;div  style="color:orangered;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;EventLogListenerTest&lt;/span&gt;.cs (18,10): &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;errorCS&lt;/span&gt;0246: The type or &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;namespace&lt;/span&gt; name '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;TestFixtureSetUpAttribute&lt;/span&gt;' could not be found (are you missing a using directive or an assembly reference?)&lt;/div&gt; &lt;div  style="color:orangered;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;EventLogListenerTest&lt;/span&gt;.cs (25,10): &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;errorCS&lt;/span&gt;0246: The type or &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;namespace&lt;/span&gt; name '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;TestFixtureTearDown&lt;/span&gt;' could not be found (are you missing a using directive or an assembly reference?)&lt;/div&gt; &lt;div  style="color:orangered;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;EventLogListenerTest&lt;/span&gt;.cs (25,10): &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;errorCS&lt;/span&gt;0246: The type or &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;namespace&lt;/span&gt; name '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;TestFixtureTearDownAttribute&lt;/span&gt;' could not be found (are you missing a using directive or an assembly reference?)&lt;/div&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;/span&gt;&lt;/div&gt;These errors are only happened when I ran &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;CruiseControl&lt;/span&gt; as a service... so I logically assumed that this must be a security issue with the Local service account not being able to see the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;Nunit&lt;/span&gt; assemblies.  However, the issue was not resolved by running the service as the logged in user.&lt;br /&gt;&lt;br /&gt;The solution I found was to manually add the Nunit.Framework.dll from the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;Nunit&lt;/span&gt; directory in "c:\program files" to the Global Assembly Cache (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;GAC&lt;/span&gt;).  This resolved all the missing assembly reference" errors.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-4554541197685566948?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/4554541197685566948/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=4554541197685566948' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4554541197685566948'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/4554541197685566948'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/08/nunit-missing-assembly-reference.html' title='NUnit missing assembly reference error'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-8978610010183707641</id><published>2008-08-20T02:56:00.000-07:00</published><updated>2008-08-20T03:18:48.869-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><category scheme='http://www.blogger.com/atom/ns#' term='XMLNS'/><title type='text'>XML Namespaces and LINQ to XML</title><content type='html'>Recently I've been writing a program to automatically generate an &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;MSBuild&lt;/span&gt; file containing all of our projects.  This is then used by &lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;CruiseControl&lt;/span&gt;.NET&lt;/a&gt; to continuously build and test our source code.&lt;br /&gt;&lt;br /&gt;I decided to use the new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;LINQ&lt;/span&gt; to XML to write the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;MSBuild&lt;/span&gt; file, but came across a problem when I ran the resulting file through &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;MSBuild&lt;/span&gt;.  The error message I received was:&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);font-family:times new roman;" &gt;The element &lt;msbuild&gt; beneath element &lt;target&gt; may not have a custom XML &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;namespace&lt;/span&gt;.&lt;/target&gt;&lt;/msbuild&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Investigation revealed that the root node of the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;MSBuild&lt;/span&gt; XML has a XML &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;namespace&lt;/span&gt; (&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;xmlns&lt;/span&gt;&lt;/span&gt;=&lt;span style="color: rgb(102, 0, 204);"&gt;"http://schemas.microsoft.com/developer/msbuild/2003"&lt;/span&gt;) and when I added a new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;XElement&lt;/span&gt; to the root element it automatically added a blank &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;namespace&lt;/span&gt; attribute to the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;XElement&lt;/span&gt;(&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;xmlns&lt;/span&gt;&lt;/span&gt;=&lt;span style="color: rgb(102, 0, 204);"&gt;""&lt;span style="color: rgb(0, 0, 0);"&gt;).  Thus causing the error message.&lt;br /&gt;&lt;br /&gt;The solution is to always add a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;XNamespace&lt;/span&gt; object of the SAME address to the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;XElement&lt;/span&gt; you are adding (see below). &lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;XNamespace&lt;/span&gt; _&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;xlmns&lt;/span&gt; = "http://schemas.microsoft.com/developer/msbuild/2003";&lt;br /&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;XElement&lt;/span&gt; root = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;XElement&lt;/span&gt;(_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;xlmns&lt;/span&gt; + "Project",&lt;br /&gt;                    new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;XAttribute&lt;/span&gt;("&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;DefaultTargets&lt;/span&gt;", "Build");&lt;br /&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;XElement&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;newBuildTarget&lt;/span&gt; = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;XElement&lt;/span&gt;(_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;xlmns&lt;/span&gt; + "&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;MSBuild&lt;/span&gt;",                   &lt;br /&gt;                           new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;XAttribute&lt;/span&gt;("Projects", &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;notShownSolutionPath&lt;/span&gt;),&lt;br /&gt;                           new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;XAttribute&lt;/span&gt;("Targets", &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;notShownTargets&lt;/span&gt;));&lt;br /&gt;root.Add(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;XElement&lt;/span&gt;); &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Bizarrely enough this will actually then remove the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;xmlns&lt;/span&gt; attribute from the added element.  But thankfully it solves the problem.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-8978610010183707641?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/8978610010183707641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=8978610010183707641' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/8978610010183707641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/8978610010183707641'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/08/xml-namespaces-and-linq-to-xml.html' title='XML Namespaces and LINQ to XML'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-152083333026201786</id><published>2008-08-14T01:20:00.000-07:00</published><updated>2008-08-14T02:28:34.922-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='WMI'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Windows Management Instrumentation (WMI) queries</title><content type='html'>Often when coding you need to access the configuration of the server that your software is running on.  This might be to determine if a particular device is connected or just to provide remote support information about the machine that the problem occured on.&lt;br /&gt;&lt;br /&gt;Microsoft have built a feature called WMI into the Windows Driver Model.  This provides an interface which you can query (using WMI queries) to access information about the system and it's components.&lt;br /&gt;&lt;br /&gt;.NET provides a namespace (System.Management) that contains classes to query and access the results returned.  The example below shows a simple example of using a query in C# to access Drive information on a specific machine.&lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 280px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using &lt;span style="color: rgb(0, 0, 0);"&gt;System.Management;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public static void &lt;span style="color: rgb(0, 0, 0);"&gt;DisplayDrives()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 153, 153);"&gt;  ManagementScope&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;scope&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt; new &lt;span style="color: rgb(51, 153, 153);"&gt;ManagementScope&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;"\\\aMachine\\root\\cimv2"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(51, 153, 153);"&gt;  ObjectQuery&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;query =&lt;/span&gt; new &lt;span style="color: rgb(51, 153, 153);"&gt;ObjectQuery&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;  "SELECT Name, Size FROM Win32_LogicalDisk where DriveType = 3"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;  &lt;span style="color: rgb(0, 153, 0);"&gt;    //N.B. 3 = local fixed drives ONLY&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 153, 153);"&gt;&lt;br /&gt;ManagementObjectCollection&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;drives = query.Get();&lt;/span&gt;&lt;br /&gt;foreach&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(51, 153, 153);"&gt;ManagementObject&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;drive&lt;/span&gt; in &lt;span style="color: rgb(0, 0, 0);"&gt;drives)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 153, 153);"&gt;   Console&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.WriteLine(&lt;/span&gt;string&lt;span style="color: rgb(0, 0, 0);"&gt;.Format(&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;"Drive:{0} Size={1}"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;br /&gt;      drive[&lt;span style="color: rgb(255, 0, 0);"&gt;"Name"&lt;/span&gt;].ToString(), drive[&lt;span style="color: rgb(255, 0, 0);"&gt;"Size"&lt;/span&gt;].ToString()));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;As you can see it's quite straightforward to use.  However, one of the problems I have come across is how you know that the Win32_LogicalDisk is the object that contains information about the drives?&lt;br /&gt;&lt;br /&gt;I use &lt;a href="http://msdn.microsoft.com/en-us/library/aa394585%28VS.85%29.aspx"&gt;this page&lt;/a&gt;, which I found hidden away in the MSDN (I won't start ranting about how difficult it is to find anything in MSDN).  It contains a break down of the different types of objects that are available for querying.  You can even view the properties they contain.&lt;br /&gt;&lt;br /&gt;I've just come across &lt;a href="http://www.bencoleman.co.uk/wmi-query-tool/"&gt;this&lt;/a&gt; application that Ben Coleman has created for running WMI queries on local or remote machines.   It's quite useful for testing your WMI queries before adding them into your code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-152083333026201786?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/152083333026201786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=152083333026201786' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/152083333026201786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/152083333026201786'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/08/windows-management-instrumentation-wmi.html' title='Windows Management Instrumentation (WMI) queries'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-1518122292267374241</id><published>2008-08-13T00:57:00.000-07:00</published><updated>2008-08-13T14:32:36.428-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Use Case'/><category scheme='http://www.blogger.com/atom/ns#' term='Project Management'/><title type='text'>Free Project Management Tools</title><content type='html'>I have spent the last few days evaluating free project &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;management&lt;/span&gt; tools, as we have decided that we'd like to plan out our latest development in a bit more detail.  I've never really been much of  a fan of Microsoft Project (a bit to overly complicated), so I have been looking for something that is easy to use and web based.&lt;br /&gt;&lt;br /&gt;The solution that I have decided to use is &lt;a href="http://studios.thoughtworks.com/mingle-project-intelligence"&gt;Mingle&lt;/a&gt; by &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Thoughtworks&lt;/span&gt;.  This is free if you have 5 users, or if you are lucky enough to work for a non-profit or charity.  The only requirements are a web server with a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;mySQL&lt;/span&gt; 5.00 database.&lt;br /&gt;&lt;br /&gt;Mingle is based around a wiki based system and uses items it calls "Cards" to store information about the project.  For example, you can create a card for each of your Use Cases and then add a card property of Requirement status which would allow you to move these cards through &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;pre&lt;/span&gt;-defined project states (such as Analysis, Design, &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_5"&gt;Implementation&lt;/span&gt; and Completed).  You can even create card trees, which in this example would allow you to break the Requirement into software engineering tasks (such as Code, Unit Test etc).&lt;br /&gt;&lt;br /&gt;Cards can also be used to keep track on defects and other project items.  Mingle is highly configurable and can be adapted to a variety of project &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_6"&gt;management&lt;/span&gt; uses.  &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_7"&gt;Thoroughly&lt;/span&gt; &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_8"&gt;recommended&lt;/span&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-1518122292267374241?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/1518122292267374241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=1518122292267374241' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/1518122292267374241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/1518122292267374241'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/08/free-project-management-tools.html' title='Free Project Management Tools'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-638911289292328226</id><published>2008-08-06T03:24:00.000-07:00</published><updated>2008-08-07T06:28:30.031-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tracing'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Debugging'/><category scheme='http://www.blogger.com/atom/ns#' term='Event Log'/><title type='text'>Custom Event Log Trace Listener</title><content type='html'>We all love .NET tracing, who wouldn't?  It's so easy to use (see &lt;a href="http://support.microsoft.com/kb/815788"&gt;here&lt;/a&gt; if you've never come across tracing before).&lt;br /&gt;&lt;br /&gt;However, recently I've come across a mild annoyance.  The standard .NET event log listener logs everything as info... great!&lt;br /&gt;&lt;br /&gt;Luckily the .NET framework provides the ability to write your own custom trace listeners, so I decided to write my own.  I have included the code for this trace listener below:&lt;br /&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Linq&lt;/span&gt;;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Diagnostics;&lt;br /&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;namespace&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;aCompany&lt;/span&gt;.Diagnostics&lt;br /&gt;{&lt;br /&gt; public class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;EventLogListener&lt;/span&gt;: &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;TraceListener&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     #region Field(s)&lt;br /&gt;     private &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;EventLog&lt;/span&gt; _&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;eventLog&lt;/span&gt;;&lt;br /&gt;     #&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;endregion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     #region Constructor(s)&lt;br /&gt;     public &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;EventLogListener&lt;/span&gt;(string &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;sourceName&lt;/span&gt;)&lt;br /&gt;     {&lt;br /&gt;         _&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;eventLog&lt;/span&gt; = new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;EventLog&lt;/span&gt;();&lt;br /&gt;         _&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;eventLog&lt;/span&gt;.Source = &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;sourceName&lt;/span&gt;;&lt;br /&gt;     }&lt;br /&gt;     #&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;endregion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     #region Public Method(s)&lt;br /&gt;     public override void Write(string message)&lt;br /&gt;     {&lt;br /&gt;         _&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;eventLog&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;WriteEntry&lt;/span&gt;(message, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;EventLogEntryType&lt;/span&gt;.Information);&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public override void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;WriteLine&lt;/span&gt;(string message)&lt;br /&gt;     {&lt;br /&gt;         this.Write(message + Environment.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;NewLine&lt;/span&gt;);&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public override void Fail(string message)&lt;br /&gt;     {&lt;br /&gt;         _&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;eventLog&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;WriteEntry&lt;/span&gt;(message, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;EventLogEntryType&lt;/span&gt;.Error);         &lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public override void Fail(string message, string &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;detailMessage&lt;/span&gt;)&lt;br /&gt;     {&lt;br /&gt;         _&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;eventLog&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;WriteEntry&lt;/span&gt;(message + Environment.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;NewLine&lt;/span&gt; + &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;detailMessage&lt;/span&gt;, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;EventLogEntryType&lt;/span&gt;.Error);&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public override void &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;WriteLine&lt;/span&gt;(string message, string category)&lt;br /&gt;     {&lt;br /&gt;         &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;EventLogEntryType&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;entryType&lt;/span&gt; = (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;EventLogEntryType&lt;/span&gt;)&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;Enum&lt;/span&gt;.Parse(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_34"&gt;typeof&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_35"&gt;EventLogEntryType&lt;/span&gt;), category);&lt;br /&gt;         _&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_36"&gt;eventLog&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_37"&gt;WriteEntry&lt;/span&gt;(message, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_38"&gt;entryType&lt;/span&gt;);&lt;br /&gt;     }&lt;br /&gt;     #&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_39"&gt;endregion&lt;/span&gt;  &lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;This listener assumes that an info event should be created if a Trace.Write() or Trace.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_40"&gt;WriteLine&lt;/span&gt;() is called.  An error event is created if Trace.Fail() is called.&lt;br /&gt;&lt;br /&gt;There is also a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_41"&gt;WriteLine&lt;/span&gt;() that takes a category as an argument.  I have used this to represent a string of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_42"&gt;EventLogEntryType&lt;/span&gt;, so this can be used to created any type of event.&lt;br /&gt;&lt;br /&gt;The event source that the events will be added to is passed in as an argument to the constructor.&lt;br /&gt;&lt;br /&gt;Hope you find this useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-638911289292328226?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/638911289292328226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=638911289292328226' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/638911289292328226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/638911289292328226'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/08/event-log-trace-listener.html' title='Custom Event Log Trace Listener'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-5104276158679416657</id><published>2008-07-28T03:49:00.001-07:00</published><updated>2008-08-11T05:59:58.014-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unit Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Bug'/><title type='text'>Visual Studio 2008 Test List Editor Bug</title><content type='html'>Monday morning: After another weekend of travelling around the country (this time London) I have returned to work and discovered a juicy bug in Visual Studio 2008. (VS)&lt;br /&gt;&lt;br /&gt;I noticed that when I closed my projects and reopened them, all the Unit Test lists disappeared from my Test List!  Investigation revealed that VS had actually replaced the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;vsmdi&lt;/span&gt; file (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;myProject&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;vsmdi&lt;/span&gt;) with a new one (&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;myProject&lt;/span&gt;1.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;vsmdi&lt;/span&gt;).  To get the original test list back you have to delete this new one and re-add the original one from the project directory.&lt;br /&gt;&lt;br /&gt;A temporary work around to get around the issue is to close the Test List Editor prior to closing the solution/project or VS.&lt;br /&gt;&lt;br /&gt;I've checked on Microsoft's connect website and this has already been reported.  &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_5"&gt;Interestingly&lt;/span&gt; enough I came across this post by Aaron &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;Stebner&lt;/span&gt; (&lt;a href="http://blogs.msdn.com/astebner/articles/451329.aspx"&gt;here!&lt;/a&gt;) about best practice when logging a Bug with Microsoft.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-5104276158679416657?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/5104276158679416657/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=5104276158679416657' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/5104276158679416657'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/5104276158679416657'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/07/visual-studio-2008-test-list-editor-bug.html' title='Visual Studio 2008 Test List Editor Bug'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8783816172041709062.post-585075504707976396</id><published>2008-07-25T03:31:00.000-07:00</published><updated>2008-07-28T03:41:44.234-07:00</updated><title type='text'>In the beginning there was light...</title><content type='html'>&lt;span style="font-family:arial;"&gt;I have been meaning to start putting together a blog for many years now.  Finally, one quiet day in the office I have finally put this together!  &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;So to start I have prepared a question and answer session with myself.  Don't worry I haven't &lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"  style="font-family:arial;"&gt;got multiple personalities.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:arial;" &gt;Q.  Why as a so called software engineer (SE) have you used the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;google&lt;/span&gt; blogging site rather than create your own site using this or that blogging software?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;A.  Okay I'm a bit lazy... also on a more serious note I think there is a mindset amongst many SE to always go and reinvent the wheel.  If &lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"  style="font-family:arial;"&gt;google&lt;/span&gt;&lt;span style="font-family:arial;"&gt; are providing this (seems to be decent) service free of charge then why should I mess around with my own site :).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:arial;" &gt;Q. What is this blog for?  Do we really need to hear the rantings of another person?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;A. Well I want to use this to share my experiences of Software Development.. and hopefully these will help other SE solve there issues.  Also, I want to add some more real life examples of using analysis and design to build "quality" software.  It seems that there is a real lack of blogs that tackle this subject.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:arial;" &gt;Q. Who are you and why should we listen to you?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;A. I am a Senior Software Engineer who is currently working for a small expense managment firm in Manchester, UK.  Before this role I was working for large firms in the Pharmaceutical sector.  I am currently working with C# and ASP.NET and have previous experience working with Delphi and Java.  Through all my career (6 years) I have used UML and Oracle Databases.&lt;/span&gt;  I have also been involved in training SE in UML and Object-Oriented analysis and design.&lt;br /&gt;&lt;span style="font-family:arial;"&gt;In answer to the other question... errr... you don't have to listen to me if you don't want to :)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8783816172041709062-585075504707976396?l=designbuildrelease.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://designbuildrelease.blogspot.com/feeds/585075504707976396/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8783816172041709062&amp;postID=585075504707976396' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/585075504707976396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8783816172041709062/posts/default/585075504707976396'/><link rel='alternate' type='text/html' href='http://designbuildrelease.blogspot.com/2008/07/in-begining-there-was-light.html' title='In the beginning there was light...'/><author><name>Iain Mitchell</name><uri>http://www.blogger.com/profile/04170887741231465144</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
