<?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-7889773289404691484</id><updated>2011-09-03T05:30:07.985-07:00</updated><category term='LINQ'/><category term='Development'/><category term='iPhone'/><category term='General'/><category term='WCF'/><category term='BDC'/><category term='Mac'/><category term='SharePoint'/><category term='Cocoa'/><category term='MonoTouch'/><category term='BCD'/><category term='Mono'/><category term='SQLite'/><category term='LinqPad'/><title type='text'>Development Notes</title><subtitle type='html'>Various notes on development environments</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://devrichardagreene.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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>98</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-6028449931180450956</id><published>2011-02-02T00:27:00.001-08:00</published><updated>2011-02-02T00:27:31.161-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Encrypting Web.Config part 2</title><content type='html'>&lt;p&gt;Someone noted that my previous script for encrypting web.config files was missing out some applications and I discovered it was because they where at the root level and my script expected everything to running under a virtual directory.&amp;#160; This was correct for the development machines but on a production machine the site could be anywhere. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Working by file &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To fix this I changed the script to simply find all the web.configs on a specific drive and do it that way.&amp;#160; It turned out to be easier than going via IIS and probably more accurate too.&amp;#160; There modified script is below:&lt;/p&gt;  &lt;p&gt;$Dir = get-childitem G:\ -recurse    &lt;br /&gt;$List = $Dir | where {$_.name -eq &amp;quot;web.config&amp;quot;} &lt;/p&gt;  &lt;p&gt;## Sections we want Hashed ###    &lt;br /&gt;$configSections = @('connectionStrings','appSettings')     &lt;br /&gt;## Command line for the encrypting system ###     &lt;br /&gt;$CmdLine = &amp;quot;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef &amp;quot; &lt;/p&gt;  &lt;p&gt;foreach($file in $List)    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ### Process the directories ###     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; write-Host &amp;quot;processing&amp;#160; -&amp;gt; &amp;quot; $file.fullname;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; foreach($section in $configSections)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $command = $CmdLine + $section + &amp;quot; &amp;quot; + $file.fullname + &amp;quot;' -prov 'RsaProtectedConfigurationProvider'&amp;quot;;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #invoke-expression -command $command | out-null     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;}&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-6028449931180450956?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6028449931180450956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6028449931180450956'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2011/02/encrypting-webconfig-part-2.html' title='Encrypting Web.Config part 2'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-293652569016599940</id><published>2011-02-01T01:13:00.001-08:00</published><updated>2011-02-01T01:13:52.029-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Encrypting Web.Config</title><content type='html'>&lt;p&gt;Today I spent a few hours getting a script together that would encrypt all the web.config files for all the sites and applications on a server.&amp;#160;&amp;#160; It was more difficult than expected, but I think that’s more because I don’t really know PowerShell as well as I figured.&amp;#160; It was also the fact that our servers are running version 1 rather than version 2 which makes things a little more complicated.&lt;/p&gt;  &lt;h3&gt;The Script&lt;/h3&gt;  &lt;p&gt;The script is given below (not much sot show for 4 hours work!).&amp;#160; &lt;/p&gt;  &lt;p&gt;### Powershell script to encrypt all web.configs###   &lt;br /&gt;$objSites = [adsi]&amp;quot;IIS://localhost/W3SVC&amp;quot;    &lt;br /&gt;foreach ($objChild in $objSites.psBase.children)    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; $sitePath=$objChild.psBase.Path + &amp;quot;/Root&amp;quot;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Write-Host &amp;quot;Processing Site:&amp;quot; + $sitePath;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; $iis=[adsi]$sitePath;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; $vroot = $iis.psbase.children ;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; trap&amp;#160; { continue;} &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; ## Sections we want Hashed ###    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; $configSections = @('connectionStrings','appSettings')    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ## Command line for the encrypting system ###    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; $CmdLine = &amp;quot;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pe &amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ### Process the directories ###    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; foreach($vdir in $vroot)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Write-Host &amp;quot;processing&amp;#160; -&amp;gt; &amp;quot; $vdir.psBase.Name;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach($section in $configSections)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $command = $CmdLine + $section + &amp;quot; -app '/&amp;quot; + $vdir.psBase.Name + &amp;quot;' -prov 'RsaProtectedConfigurationProvider'&amp;quot;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; invoke-expression -command $command | out-null    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;In essence its a simple loop, find all teh defined sites, then all the virtual directories below these.&amp;#160; Run teh command line utility “aspnet-regiis –pe ”, which will work it’s magic.&lt;/p&gt;  &lt;h3&gt;Powershell&lt;/h3&gt;  &lt;p&gt;One of the major things you need to have on teh server for this work is PowerShell.&amp;#160; This feature is built into Windows 2008 so all you need to do is enable it by adding the “Microsoft Powershell” feature.&amp;#160; For Windows 2003 you’ll need to download the installation package from Microsoft.&lt;/p&gt;  &lt;p&gt;If you’ve installed PowerShell for teh first time tehn you’ll also need to set th Execution Policy.&amp;#160; Just enter “Powershell” at the command prompet and enter “Set-ExecutionPolicy RemoteSigned”, then exit.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;The Timer Job&lt;/h3&gt;  &lt;p&gt;The simplest way of making sure that this is always applied to all sites is to create a timer job that runs every hour.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-293652569016599940?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/293652569016599940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/293652569016599940'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2011/02/encrypting-webconfig.html' title='Encrypting Web.Config'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-659277909274493911</id><published>2010-12-06T23:44:00.001-08:00</published><updated>2010-12-06T23:44:13.603-08:00</updated><title type='text'>Mocking a View for Unit Testing</title><content type='html'>&lt;p&gt;Had a very interesting question yesterday asking if it was possible to mock up a database view along side the in-memory SQLLite database we use for ActiveRecord.&amp;#160; Initially I figured it was a simple matter of just finding some form of attribute within the ActiveRecord class definition but it turns out that this is not the case.&amp;#160; Views not not actually supported by the CreateSchema() method we normally use with NHibernate/ActiveRecord.&lt;/p&gt;  &lt;p&gt;As a work around you can create a view using the existing connection, for example I want to create a view called “mockview” which is based on the applications table.&amp;#160; All we need to do this is create a method:&lt;/p&gt;  &lt;p&gt;private void CreateMockView()    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; using (IDbCommand command = service.GetConnection().CreateCommand())     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; command.CommandText = &amp;quot;Create view mockview as select applicationid from applications&amp;quot;;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; command.ExecuteNonQuery();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;If there is already an ActiveRecord class definition for this you need to decorate the class with the Schema=”none” parameter which will prevent the creation of a table with the same name.&lt;/p&gt;  &lt;p&gt;[Serializable , ActiveRecord(&amp;quot;mockview &amp;quot;, DynamicUpdate = true, Lazy = false, &lt;strong&gt;Schema=&amp;quot;none&amp;quot;)]      &lt;br /&gt;&lt;/strong&gt;public partial class ApplicationsDAO : ActiveRecordBase&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;………………………….     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Now you can query this to your hearts content.&lt;/p&gt;  &lt;p&gt;If we want to query this but there is no ActiveRecord table definition we can just use a normal datareader, for example;&lt;/p&gt;  &lt;p&gt;[Test]    &lt;br /&gt;public void GetApplications_Test()     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; IList&amp;lt;Application&amp;gt; results = Application.FindAll();&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // the AR Class     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(results.Count &amp;gt; 0, &amp;quot;Returned values&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; _log.InfoFormat(&amp;quot;GetAll Complete returned {0} records&amp;quot;, results.Count); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; using (IDbCommand command = service.GetConnection().CreateCommand())    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; command.CommandText = &amp;quot;select applicationid from applications&amp;quot;;&amp;#160; // the View on the database     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IDataReader reader = command.ExecuteReader();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(reader[&amp;quot;applicationid&amp;quot;].ToString() == “1”, &amp;quot;there should be records in the view!&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-659277909274493911?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/659277909274493911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/659277909274493911'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/12/mocking-view-for-unit-testing.html' title='Mocking a View for Unit Testing'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-478016913646169886</id><published>2010-11-24T03:42:00.001-08:00</published><updated>2010-11-24T03:42:44.282-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Authentication against Active Directory and ADAM</title><content type='html'>&lt;p&gt;Today we were doing some work with authentication to see if we can improve the way it’s done on the external environments, Corp Website, Xtranet and the CEBs.&amp;#160; The plan was to use ADAM (Active Directory Application Mode) but this would mean a lot of nice features that are out-of-the-box with Active Directory.&lt;/p&gt;  &lt;p&gt;To test both options I created a simple winform that will verify both options.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/TOz6L5av7II/AAAAAAAAAnk/OrNihPJfXcs/s1600-h/image%5B2%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="244" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/TOz6MSH8d6I/AAAAAAAAAno/L5hs_mJtJ1w/image_thumb.png?imgmax=800" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;Using Active Directory&lt;/h3&gt;  &lt;p&gt;This is very well supported in the .Net Framework, you can use the built-in .Net references:   &lt;br /&gt;System.DirectoryServices.AccountManagement;    &lt;br /&gt;System.DirectoryServices;&lt;/p&gt;  &lt;p&gt;Here is the code;&lt;/p&gt;  &lt;p&gt;try   &lt;br /&gt;{&amp;#160; &lt;br /&gt;&amp;#160; // create a &amp;quot;principal context&amp;quot; - e.g. the domain (can also be a machine, too)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; using (&lt;strong&gt;PrincipalContext&lt;/strong&gt; &lt;strong&gt;pc = new PrincipalContext(ContextType.Domain, txtDomain.Text))     &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // validate the credentials     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (&lt;strong&gt;pc.ValidateCredentials(txtUsername.Text, txtPassword.Text))     &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lblStatus.Text = &amp;quot;Login successful!&amp;quot;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lblStatus.Text = &amp;quot;Login unsuccessful!&amp;quot;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;}    &lt;br /&gt;catch (Exception ex)    &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; lblStatus.Text = ex.Message;    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;The PrincipleContext connects you to the domain, while the ValidateCredentials method will return True if its a valid name/password pair and false if not.&lt;/p&gt;  &lt;h3&gt;Using ADAM&lt;/h3&gt;  &lt;p&gt;This is not as well supported but it is there if needed.&lt;/p&gt;  &lt;p&gt;try    &lt;br /&gt; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; using (&lt;strong&gt;DirectoryEntry entry = new DirectoryEntry(txtPath.Text, txtUsername.Text, txtPassword.Text&lt;/strong&gt;))    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; try    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (entry.Guid != null)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lblStatus.Text = &amp;quot;Login successful!&amp;quot;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lblStatus.Text = &amp;quot;Login unsuccessful!&amp;quot;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; catch (NullReferenceException ex)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lblStatus.Text = ex.Message;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt; }    &lt;br /&gt; catch (Exception ex)    &lt;br /&gt; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lblStatus.Text = ex.Message;    &lt;br /&gt; }&lt;/p&gt;  &lt;p&gt;Here we create a Directory entry and connect to it using an LDAP path.&amp;#160; That is we tell the application where to find the Users information.&amp;#160; In my form I used; &lt;a href="ldap://localhost:389/cn=Groups,cn=XXX,cn=YYY,dc=ZZZ"&gt;LDAP://localhost:389/cn=Groups,cn=XXX,cn=YYY,dc=ZZZ&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The important thing here is that the address is entered in reverse order.&amp;#160; You enter the container for the User, then the container in which the User is located and ten any other container and so on until the top.&lt;/p&gt;  &lt;p&gt;Someone might find it useful, but I’m happy to stick with Active Directory.   &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-478016913646169886?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/478016913646169886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/478016913646169886'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/11/authentication-against-active-directory.html' title='Authentication against Active Directory and ADAM'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh6.ggpht.com/_r_B45UywYok/TOz6MSH8d6I/AAAAAAAAAno/L5hs_mJtJ1w/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-6958281346131331585</id><published>2010-11-17T05:36:00.001-08:00</published><updated>2010-11-17T05:36:18.285-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Running SQL scripts in PowerShell</title><content type='html'>&lt;p&gt;I had the requirement to create a power shell script that would query a SQL database.&amp;#160; It turned out to be very easy indeed…&lt;/p&gt;  &lt;p&gt;# Create SqlConnection object, define connection string, and open connection    &lt;br /&gt;$con = New-Object System.Data.SqlClient.SqlConnection     &lt;br /&gt;$con.ConnectionString = &amp;quot;Server=Livesqlserver; Database=WebCDB; Integrated Security=true&amp;quot;     &lt;br /&gt;$con.Open() &lt;/p&gt;  &lt;p&gt;First create the connection…&lt;/p&gt;  &lt;p&gt;$cmdSelect = &amp;quot;SELECT DATEDIFF(day, update_date, getdate()) as datedifference, DATENAME(dw, update_date) as theday , count(*)as TotalMails FROM&amp;#160; mail_tbl where sent=1 and mail_type='XTRANET' and&amp;#160; DATEDIFF(day, update_date, getdate()) &amp;lt; 7 group by DATEDIFF(day, update_date, getdate()), DATENAME(dw, update_date) order by datedifference desc&amp;quot;    &lt;br /&gt;$da = New-Object System.Data.SqlClient.SqlDataAdapter($cmdSelect, $con) &lt;/p&gt;  &lt;p&gt;Create the SQL you want to return values on..&lt;/p&gt;  &lt;p&gt;$dt = New-Object System.Data.DataTable    &lt;br /&gt;$da.Fill($dt) | Out-Null &lt;/p&gt;  &lt;p&gt;Fill a dataset with the results&lt;/p&gt;  &lt;p&gt;Foreach ($row in $dt.rows)    &lt;br /&gt;{&amp;#160; Write-Host $row.theday $row.TotalMails&amp;#160; } &lt;/p&gt;  &lt;p&gt;Print out the results… easy&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-6958281346131331585?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6958281346131331585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6958281346131331585'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/11/running-sql-scripts-in-powershell.html' title='Running SQL scripts in PowerShell'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2295860792409286129</id><published>2010-11-03T00:43:00.001-07:00</published><updated>2010-11-03T00:43:38.838-07:00</updated><title type='text'>Workflow work-around made easy</title><content type='html'>&lt;p&gt;I had a typical User request today, you know the type of thing “We have a rules that says ‘Reporting is always to Managers’, but we’ve these two people people who are ‘Manager’, but report to other ‘Managers’”.&amp;#160; “Simple”, I said&amp;quot;, “Just don’t call them Managers”.. “Ahh yeah..but we can’t do that!” was the reply. You know yourself usual things we get thrown every now and again.&amp;#160; So I figured I could do something that was a little but better than just the usual big “If” statement, so I’ve implemented the Strategy Pattern. &lt;/p&gt;  &lt;h3&gt;Before the good stuff&lt;/h3&gt;  &lt;p&gt;The code used to look like this a big if statement which did a recursive call to itself, if the person was a Manager, Divisional Manager, Director or CEO then that was fine, if not try the next person. &lt;/p&gt;  &lt;p&gt;/// &amp;lt;summary&amp;gt;    &lt;br /&gt;/// Finds the next in line by post ID.     &lt;br /&gt;/// &amp;lt;/summary&amp;gt;     &lt;br /&gt;/// &amp;lt;param name=&amp;quot;Id&amp;quot;&amp;gt;The id.&amp;lt;/param&amp;gt;     &lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;     &lt;br /&gt;public ReportingStructure FindNextInLineByPostID(string Id)     &lt;br /&gt;{     &lt;br /&gt;IList&amp;lt;ReportingStructure&amp;gt; records = ReportingStructure.FindAll(Expression.Eq(&amp;quot;PostId&amp;quot;, Id));     &lt;br /&gt;if (records.Count &amp;gt; 0)     &lt;br /&gt;{&amp;#160;&amp;#160; // OK now we have to check if this is a department or overseas Manager by the title     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (records[0].JobTitleDescription.Contains(&amp;quot;Department Manager&amp;quot;) ||     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; records[0].JobTitleDescription.Contains(&amp;quot;Overseas Manager&amp;quot;) ||     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; records[0].JobTitleDescription.Contains(&amp;quot;Divisional&amp;quot;) ||     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; records[0].JobTitleDescription.Contains(&amp;quot;Director&amp;quot;) ||     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; records[0].JobTitleDescription.Contains(&amp;quot;Chief Executive Officer&amp;quot;)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; )     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return records[0];     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // not an exec so move up the line     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return NextInLine(records[0].ReportsToPostId);     &lt;br /&gt;}     &lt;br /&gt;return null;     &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;So I figured, hey I’ll just hard code in the two exceptions; but then it occurred to me that this could (and probably would) change over time.&amp;#160; More exceptions would be added, more code and next year it might all change again. &lt;/p&gt;  &lt;h3&gt;Getting down with Strategy &lt;/h3&gt;  &lt;p&gt;This is really easy once you get your head around it.&amp;#160; First we create an abstract class with an abstract method.&amp;#160; This will be the blue-print for the class we’ll use for our reporting strategy. &lt;/p&gt;  &lt;p&gt;abstract class ReportingStrategy    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public abstract ReportingStructure NextInLine(string Id);     &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;Next we create a concrete class that contains the code we want to implement. &lt;/p&gt;  &lt;p&gt;internal class Reporting2010 : ReportingStrategy    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public override ReportingStructure NextInLine(string Id)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IList&amp;lt;ReportingStructure&amp;gt; records = ReportingStructure.FindAll(Expression.Eq(&amp;quot;PostId&amp;quot;, Id));     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (records.Count &amp;gt; 0)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&amp;#160;&amp;#160; // OK now we have to check if this is a department Manager or overseas     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (records[0].JobTitleDescription.Contains(&amp;quot;Department Manager&amp;quot;) ||     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; records[0].JobTitleDescription.Contains(&amp;quot;Department Manager&amp;quot;) ||     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; records[0].JobTitleDescription.Contains(&amp;quot;Divisional&amp;quot;) ||     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; records[0].JobTitleDescription.Contains(&amp;quot;Director&amp;quot;) ||     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; records[0].JobTitleDescription.Contains(&amp;quot;Chief Executive Officer&amp;quot;)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; )     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return records[0];     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // not an exec so move up the line     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return NextInLine(records[0].ReportsToPostId);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return null;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;As you will see this is the same workflow logic as before but now it’s out on it’s own in its own class. &lt;/p&gt;  &lt;p&gt;Finally we update the context class to make use of this new object. I’ve clipped out all the other code to make it easier to read. &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public class ReportingStructure&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; { &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #region Private Members    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ……….&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private ReportingStrategy _reportingStrategy = new Reporting2010();      &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #endregion&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;public ReportingStructure FindNextInLineByPostID(string Id)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return _reportingStrategy.NextInLine(Id);&lt;/p&gt;    &lt;p&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;h3&gt;So what does that give us?&lt;/h3&gt;  &lt;p&gt;Well, now if I want to make a change to the 2010 workflow I can simply update a small specific class, which can also be use in other places if needed.&amp;#160; More importantly however I can create any number of specific new workflows and rules and just swap out the private member to point to the right one.&amp;#160; I can even make it public or build it into the constructer to allow dependency injection.&lt;/p&gt;  &lt;p&gt;e.g.&amp;#160;&amp;#160; ReportingStructure reporting = new ReportingStructure (new Reporting2011());&lt;/p&gt;  &lt;p&gt;or&amp;#160;&amp;#160;&amp;#160;&amp;#160; ReportingStructure reprting = new ReportingStructure();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; reporting.Workflow = new (ReportingWhatEverIWant();&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2295860792409286129?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2295860792409286129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2295860792409286129'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/11/workflow-work-around-made-easy.html' title='Workflow work-around made easy'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-4334587058407966588</id><published>2010-11-01T00:45:00.001-07:00</published><updated>2010-11-01T00:45:02.136-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Charting in ASP.NET and Visual Studio 2008</title><content type='html'>&lt;p&gt;I was doing some VS2010 migration research over the weekend and found that the Charting options available are really good, we could finally rid ourselves of our old Dundus Charting software.&amp;#160; My heart sank when I came back to the other problems in moving from VS2008 to VS2010, but after a bit of searching I found that all the charting options are backwardly compatible.&lt;/p&gt;  &lt;h3&gt;Things to install&lt;/h3&gt;  &lt;p&gt;You need to install two items onto your desktop development PC, both are very simple self extractors.&amp;#160; It would be best to close Visual Studio before doing this, but I don’t think it would make a lot of difference.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&amp;amp;DisplayLang=en" href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&amp;amp;DisplayLang=en"&gt;Microsoft Chart Controls for Microsoft .NET Framework 3.5&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=1d69ce13-e1e5-4315-825c-f14d33a303e9&amp;amp;displaylang=en" target="_blank"&gt;Microsoft Chart Controls Add-on for Microsoft Visual Studio 2008&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Following the installation you should now have a new Chart option available in your Data tool bar.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/TM5v8DwfhLI/AAAAAAAAAm8/LgZvnvc_5Mg/s1600-h/image%5B2%5D.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/TM5v8lz6aYI/AAAAAAAAAnE/RiAmz7NX5vA/image_thumb.png?imgmax=800" width="107" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;Using the new graph facilities&lt;/h3&gt;  &lt;p&gt;To create a simple graph I just created a new ASP.NET application with a single ASPX page called default. Dragging a chart from the toolbar to the design surface and switch to the source view will give you the code below.&lt;/p&gt;  &lt;p&gt;&amp;lt;asp:Chart ID=&amp;quot;Chart1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Series&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:Series Name=&amp;quot;Series1&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/asp:Series&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Series&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ChartAreas&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:ChartArea Name=&amp;quot;ChartArea1&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/asp:ChartArea&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/ChartAreas&amp;gt;     &lt;br /&gt;&amp;lt;/asp:Chart&amp;gt;&lt;/p&gt;  &lt;p&gt;First thing we need to do is add soem values.&amp;#160; I could do this a code behind, but for this demo I’ll just use the page code.&lt;/p&gt;  &lt;p&gt;&amp;lt;asp:Series Name=&amp;quot;Column&amp;quot; BorderColor=&amp;quot;180, 26, 59, 105&amp;quot; YValuesPerPoint=&amp;quot;2&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;points&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:DataPoint YValues=&amp;quot;45,0&amp;quot; AxisLabel=&amp;quot;Jan&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:DataPoint YValues=&amp;quot;34,0&amp;quot; AxisLabel=&amp;quot;Feb&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:DataPoint YValues=&amp;quot;67,0&amp;quot; AxisLabel=&amp;quot;Mar&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:DataPoint YValues=&amp;quot;31,0&amp;quot; AxisLabel=&amp;quot;Apr&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:DataPoint YValues=&amp;quot;27,0&amp;quot; AxisLabel=&amp;quot;May&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:DataPoint YValues=&amp;quot;87,0&amp;quot; AxisLabel=&amp;quot;Jun&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:DataPoint YValues=&amp;quot;45,0&amp;quot; AxisLabel=&amp;quot;Jul&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:DataPoint YValues=&amp;quot;32,0&amp;quot; AxisLabel=&amp;quot;Aug&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/points&amp;gt;     &lt;br /&gt;&amp;lt;/asp:Series&amp;gt; &lt;/p&gt;  &lt;p&gt;Here I’ve added 8 random numbers and given them a label for each month.&amp;#160; Next we add in the chart area code.&lt;/p&gt;  &lt;p&gt;&amp;lt;asp:ChartArea Name=&amp;quot;ChartArea1&amp;quot; BorderColor=&amp;quot;64, 64, 64, 64&amp;quot; BorderDashStyle=&amp;quot;Solid&amp;quot; BackSecondaryColor=&amp;quot;White&amp;quot; BackColor=&amp;quot;64, 165, 191, 228&amp;quot; ShadowColor=&amp;quot;Transparent&amp;quot; BackGradientStyle=&amp;quot;TopBottom&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;area3dstyle Rotation=&amp;quot;10&amp;quot; perspective=&amp;quot;10&amp;quot; Inclination=&amp;quot;15&amp;quot; IsRightAngleAxes=&amp;quot;False&amp;quot; wallwidth=&amp;quot;0&amp;quot; IsClustered=&amp;quot;False&amp;quot;&amp;gt;&amp;lt;/area3dstyle&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;axisy linecolor=&amp;quot;64, 64, 64, 64&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;labelstyle font=&amp;quot;Trebuchet MS, 8.25pt, style=Bold&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;majorgrid linecolor=&amp;quot;64, 64, 64, 64&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/axisy&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;axisx linecolor=&amp;quot;64, 64, 64, 64&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;labelstyle font=&amp;quot;Trebuchet MS, 8.25pt, style=Bold&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;majorgrid linecolor=&amp;quot;64, 64, 64, 64&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/axisx&amp;gt;     &lt;br /&gt;&amp;lt;/asp:ChartArea&amp;gt; &lt;/p&gt;  &lt;p&gt;Doing a preview will give you the following error: “Error executing child request for ChartImg.axd”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/TM5v897bZKI/AAAAAAAAAnI/lUcndRsncGg/s1600-h/image%5B5%5D.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="110" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/TM5v9YIdQHI/AAAAAAAAAnM/wEaXstwdPMk/image_thumb%5B1%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So what went wrong?&amp;#160; Well, as all the charts are generated on the fly, we need to make a few changes in the Web.Config.&amp;#160; Add the following&amp;#160; lines and all should be well;&amp;#160; &lt;/p&gt;  &lt;p&gt;Within &amp;lt;system.web&amp;gt;&amp;lt;httpHandlers&amp;gt;, add the following: &amp;lt;add path=&amp;quot;ChartImg.axd&amp;quot; verb=&amp;quot;GET,HEAD&amp;quot; type=&amp;quot;System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;quot; validate=&amp;quot;false&amp;quot; /&amp;gt;&lt;/p&gt;  &lt;p&gt;Within &amp;lt;system.webServer&amp;gt;&amp;lt;handlers&amp;gt;, add the following: &lt;/p&gt;  &lt;p&gt;&amp;lt;add name=&amp;quot;ChartImageHandler&amp;quot; preCondition=&amp;quot;integratedMode&amp;quot; verb=&amp;quot;GET,HEAD,POST&amp;quot; path=&amp;quot;ChartImg.axd&amp;quot; type=&amp;quot;System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;quot; /&amp;gt;&lt;/p&gt;  &lt;p&gt;Now when we run the programme, we get the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/TM5v9iTDeEI/AAAAAAAAAnQ/2FFkyGDsYpw/s1600-h/image%5B8%5D.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="156" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/TM5v9ymS-HI/AAAAAAAAAnU/5h86IF1t4aE/image_thumb%5B2%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;Putting on a bit more flash on our creation&lt;/h3&gt;  &lt;p&gt;Ok that graph looks a bit dull, so we add a legend and border by adding the following code to the page;&lt;/p&gt;  &lt;p&gt;&amp;lt;legends&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:Legend IsTextAutoFit=&amp;quot;False&amp;quot; Name=&amp;quot;Default&amp;quot; BackColor=&amp;quot;Transparent&amp;quot; Font=&amp;quot;Trebuchet MS, 8.25pt, style=Bold&amp;quot;&amp;gt;&amp;lt;/asp:Legend&amp;gt;     &lt;br /&gt;&amp;lt;/legends&amp;gt;     &lt;br /&gt;&amp;lt;borderskin skinstyle=&amp;quot;Emboss&amp;quot;&amp;gt;&amp;lt;/borderskin&amp;gt; &lt;/p&gt;  &lt;p&gt;Then we change the type to “Area” by modifying the series properties;&lt;/p&gt;  &lt;p&gt;&amp;lt;asp:Series Name=&amp;quot;Column&amp;quot; BorderColor=&amp;quot;180, 26, 59, 105&amp;quot; YValuesPerPoint=&amp;quot;2&amp;quot; &lt;strong&gt;ChartType=&amp;quot;Area&amp;quot;&amp;gt;&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;Now it looks like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/TM5v-L__WKI/AAAAAAAAAnY/_6S0T0C5Qdg/s1600-h/image%5B14%5D.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="163" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/TM5v-vgAQCI/AAAAAAAAAnc/DF_aKq2U2TY/image_thumb%5B4%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Its simple easy to use and very powerful and should be compatible with SharePoint.&amp;#160; It may not be Sliverlight, but it work… &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-4334587058407966588?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4334587058407966588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4334587058407966588'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/11/charting-in-aspnet-and-visual-studio.html' title='Charting in ASP.NET and Visual Studio 2008'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh3.ggpht.com/_r_B45UywYok/TM5v8lz6aYI/AAAAAAAAAnE/RiAmz7NX5vA/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-9172576630268897602</id><published>2010-10-29T04:58:00.001-07:00</published><updated>2010-10-29T05:03:19.517-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Getting Jiggy with Ajax and fields</title><content type='html'>&lt;p&gt;I was asked to do something that I’ve done a million times before the other day, link a drop down field to a radio button so depending on what is selected the list of option should reduce.  I decided to use Ajax and JQuery to do all the hard work and also because its really good at what it does.&lt;/p&gt;  &lt;p&gt;The first requirement was to have a number of radio buttons on screen each showing the name of a department.  These were very simple at first, not even taken from the database.  So I created a very simple bit of HTML…&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&amp;lt;html xmlns="&lt;a href="http://www.w3.org/1999/xhtml%22"&gt;http://www.w3.org/1999/xhtml"&lt;/a&gt; &amp;gt;   &lt;br /&gt;&amp;lt;head&amp;gt;   &lt;br /&gt;    &amp;lt;title&amp;gt;Ajax Demo&amp;lt;/title&amp;gt;   &lt;br /&gt;&amp;lt;/head&amp;gt;   &lt;br /&gt;&amp;lt;body&amp;gt;   &lt;br /&gt;    Corporate &amp;lt;input type="radio" id="radio1" name="BU" value="Corporate" /&amp;gt;&amp;lt;br /&amp;gt;   &lt;br /&gt;    Food &amp;lt;input type="radio" id="radio2" name="BU" value="Food" /&amp;gt;&amp;lt;br /&amp;gt;   &lt;br /&gt;    Investment &amp;lt;input type="radio" id="radio3" name="BU" value="Investment" /&amp;gt;&amp;lt;br /&amp;gt;   &lt;br /&gt;    &amp;lt;select id="department"&amp;gt;   &lt;br /&gt;    &amp;lt;option value="0"&amp;gt;-- No business unit selected --&amp;lt;/option&amp;gt;   &lt;br /&gt;    &amp;lt;/select&amp;gt;   &lt;br /&gt;&amp;lt;/body&amp;gt;   &lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/p&gt;  &lt;p&gt;Nothing crazy here, just your basic setup, with three radio buttons and a select box with no values.  It would look like this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/TMq23PgRBLI/AAAAAAAAAmk/zF5OnPdvDd4/s1600-h/image%5B5%5D.png"&gt;&lt;img title="image" style="border: 0px none; display: inline;" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/TMq23X-VGBI/AAAAAAAAAmo/w4W6KjPrYr8/image_thumb%5B1%5D.png?imgmax=800" border="0" height="155" width="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;Adding the Ajax bit&lt;/h3&gt;  &lt;p&gt;Now we need to implement JQuery onto the page, and we do this by including the latest script file.  You can get this on the internet, via a content delivery network or just download it.  I’ve taken a copy as its quicker.&lt;/p&gt;  &lt;p&gt;  &amp;lt;script type="text/javascript" src="template/scripts/jquery-1.4.2.min.js"&amp;gt;&amp;lt;/script&amp;gt; &lt;/p&gt;  &lt;p&gt;The line above adds the JQuery script into the page your are working with.&lt;/p&gt;  &lt;p&gt;Below is the script to do all the wor, I’ve highlighted the interesting bit.  &lt;/p&gt;  &lt;p&gt;  &amp;lt;script type="text/javascript" language="javascript"&amp;gt;  &lt;br /&gt;        $(document).ready(function() {   &lt;br /&gt;&lt;strong&gt;            $("input[name*='BU']").click(function() {    &lt;br /&gt;                callAjax($(this).val());     &lt;br /&gt;            });     &lt;br /&gt;&lt;/strong&gt;        }); &lt;/p&gt;  &lt;p&gt;        function callAjax(val) { &lt;/p&gt;  &lt;p&gt;            var selectedValue = val;  &lt;br /&gt;            var servletUrl = '&lt;a href="http://&amp;amp;%7e%7especial_remove%21/#%7E%7Elt;server&amp;amp;%7E%7ESPECIAL_REMOVE%21#%7E%7Egt;/OrganisationChartDataService.svc/Departments/%27"&gt;/OrganisationChartDataService.svc/Departments/'"&amp;gt;http://&amp;lt;server&amp;gt;/OrganisationChartDataService.svc/Departments/'&lt;/a&gt; + val + '/JSon'; &lt;/p&gt;  &lt;p&gt;         &lt;strong&gt;   $.getJSON(servletUrl, function(options) {    &lt;br /&gt;&lt;/strong&gt;                var department = $('#department');   &lt;br /&gt;                $('&amp;gt;option', department).remove(); // Clean old options first.   &lt;br /&gt;                $.each(options, function(index) {   &lt;br /&gt;                    department.append($('&amp;lt;option/&amp;gt;').val(options[index].Id).text(options[index].Name));   &lt;br /&gt;                });   &lt;br /&gt;            }); &lt;/p&gt;  &lt;p&gt;        } &lt;/p&gt;  &lt;p&gt;    &amp;lt;/script&amp;gt;&lt;/p&gt;  &lt;p&gt;The first section binds a “click” function to any element on the page with the name “BU”.  This is handy because we don’t have to write a separate function for each element and if we add more we don’t have to do anything, it will just work.&lt;/p&gt;  &lt;p&gt;The second highlighted bit is teh call to a WCF web service that takes in the name of a business Unit as being part of the URL, what’s returned can then be added to the select list.&lt;/p&gt;  &lt;p&gt;The results can be see below, its fast simple and very powerful.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/TMq231AkukI/AAAAAAAAAms/PlBoaGRsdco/s1600-h/image%5B8%5D.png"&gt;&lt;img title="image" style="border: 0px none; display: inline;" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/TMq24fHFF_I/AAAAAAAAAmw/4034KkCmm8E/image_thumb%5B2%5D.png?imgmax=800" border="0" height="217" width="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;clicking another item shows this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/TMq24vkmF-I/AAAAAAAAAm0/ts7TdiLFn1A/s1600-h/image%5B11%5D.png"&gt;&lt;img title="image" style="border: 0px none; display: inline;" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/TMq249WokGI/AAAAAAAAAm4/OZKNx5_4smU/image_thumb%5B3%5D.png?imgmax=800" border="0" height="195" width="244" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-9172576630268897602?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/9172576630268897602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/9172576630268897602'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/10/getting-jiggy-with-ajax-and-fiends.html' title='Getting Jiggy with Ajax and fields'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh5.ggpht.com/_r_B45UywYok/TMq23X-VGBI/AAAAAAAAAmo/w4W6KjPrYr8/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-6089165940645405750</id><published>2010-10-20T06:30:00.001-07:00</published><updated>2010-10-20T06:30:41.708-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Old school CSV without creating a temp file</title><content type='html'>&lt;p&gt;I had a request to export a report out to Excel today, which is something I’ve done a bunch of times before but always by producing a temporary file.&amp;#160; I figured I’d try something different, find a way to give me the same functions without having to worry about permissions on the file system, or deleting the files afterwards.&lt;/p&gt;  &lt;p&gt;It turned out to be very easy… use a TextStream that writes out&amp;#160; a HTML header so Explorer does all the hard work. &lt;/p&gt;  &lt;h3&gt;On the ASPX page…&lt;/h3&gt;  &lt;p&gt;On the click event for the export button we turn off the usual ASP.NET view state stuff and make a new header with the content type of &amp;quot;application/vnd.ms-excel&amp;quot;, this tells IE to start Excel regardless of the details sent.&amp;#160; Another interesting thing to see here is the Response.End call, you’ll need this to prevent ASP.NET sending the page refresh information along with your data.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;protected void ExportButton_Click(object sender, EventArgs e)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this.EnableViewState = false;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Response.Clear();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Response.Buffer = true;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;Response.ContentType = &amp;quot;application/vnd.ms-excel&amp;quot;;        &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Response.AddHeader(&amp;quot;Content-Disposition&amp;quot;, &amp;quot;inline;filename=TeamExport.csv&amp;quot;);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; team.ExportToExcel(Response.Output, true);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Response.Charset = &amp;quot;&amp;quot;;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;Response.End();        &lt;br /&gt;&lt;/strong&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;On the Business Object its a simple matter of building up an array of results, making sure to wrap them in “” for each field.&amp;#160; Then added this to the HTML TextStream …..&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;/// &amp;lt;summary&amp;gt;      &lt;br /&gt;/// Export Global Team lists to Excel       &lt;br /&gt;/// &amp;lt;/summary&amp;gt;       &lt;br /&gt;/// &amp;lt;param name=&amp;quot;httpStream&amp;quot;&amp;gt;The HTTP stream.&amp;lt;/param&amp;gt;       &lt;br /&gt;public void ExportToExcel(&lt;strong&gt;TextWriter httpStream&lt;/strong&gt;)       &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // find all associated applications       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IList&amp;lt;Application&amp;gt; applications =&amp;#160; (from application in Application.FindAllByProperty(&amp;quot;GlobalTeam&amp;quot;, Id)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; select application).ToList&amp;lt;Application&amp;gt;(); &lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach(Application app in applications)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string[] dataArr = new string[]       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WriteableValue(app.Id),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WriteableValue(app.GlobalTeamName),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WriteableValue(app.Title),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WriteableValue(app.SupportManager),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WriteableValue(app.ProjectManager),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WriteableValue(app.StartDate.ToShortDateString()),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WriteableValue(app.EndDate.ToShortDateString())       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; };       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; httpStream.WriteLine(string.Join(&amp;quot;,&amp;quot;, dataArr));       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/p&gt;    &lt;p&gt;public static string WriteableValue(object o)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (o == null || o == null)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return &amp;quot;&amp;quot;;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; else       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return &amp;quot;\&amp;quot;&amp;quot; + o.ToString() + &amp;quot;\&amp;quot;&amp;quot;;       &lt;br /&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Its good to rediscover something old, simple but yet works so well ….&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-6089165940645405750?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6089165940645405750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6089165940645405750'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/10/old-school-csv-without-creating-temp.html' title='Old school CSV without creating a temp file'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-8980109488251226975</id><published>2010-10-14T06:36:00.000-07:00</published><updated>2010-10-20T06:37:20.994-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>More pain with Windows x64 migration</title><content type='html'>&lt;p&gt;You have no idea how hard it was to get this to work!.&amp;#160; following on from my last posting I moved over from Windows XP to Windows 7 on x64 for development.&amp;#160; Although there was some pain in setting up the VB COMs it was nothing to the suffering when it comes to Registry settings.&lt;/p&gt;  &lt;p&gt;Some applications were continually giving Generic 500 errors with little or nothing in the Event Logs, so I presumed it was a security problem.&amp;#160; Following many hours of messing about, it turns out I was on the wrong track altogether.&amp;#160; The specific COMs were failing because they were looking for Registry settings…&lt;/p&gt;  &lt;p&gt;All the settings had been imported into their usual position under &lt;strong&gt;HKEY_LOCAL_MACHINE\SOFTWARE\SomeApplication&lt;/strong&gt;, but no matter what I did the values always came back null.&amp;#160; &lt;/p&gt;  &lt;h3&gt;The solution&lt;/h3&gt;  &lt;p&gt;The answer was hidden away in a MS support article (&lt;a title="http://support.microsoft.com/kb/896459" href="http://support.microsoft.com/kb/896459"&gt;http://support.microsoft.com/kb/896459&lt;/a&gt;) &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;32-bit programs and 64-bit programs that are running on an x64-based version of Windows operate in different modes and use the following sections in the registry:&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;Native mode 64-bit programs run in Native mode and access keys and values that are stored in the following registry sub key:        &lt;br /&gt;&lt;strong&gt;HKEY_LOCAL_MACHINE\Software&lt;/strong&gt; &lt;/li&gt;      &lt;li&gt;32-bit programs run in WOW64 mode and access keys and values that are stored in the following registry sub key:        &lt;br /&gt;&lt;strong&gt;HKEY_LOCAL_MACHINE\Software\WOW6432node&lt;/strong&gt; &lt;/li&gt;   &lt;/ul&gt; &lt;/blockquote&gt;  &lt;p&gt;So adding a copy of the REG settings to this second location made everything work again.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-8980109488251226975?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/8980109488251226975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/8980109488251226975'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/10/more-pain-with-windows-x64-migration.html' title='More pain with Windows x64 migration'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-4407951178606005776</id><published>2010-10-05T06:15:00.001-07:00</published><updated>2010-10-05T06:15:44.037-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Setting up Windows 7 for Classic ASP</title><content type='html'>&lt;p&gt;I’ve decided to move over from using the slow VPN to local development so decided to setup some old classic ASP applications on my local machine which is running IIS 7.5.&amp;#160; Unfortunately this process was far from easy.&lt;/p&gt;  &lt;h3&gt;Setting up IIS&lt;/h3&gt;  &lt;p&gt;First you need to be able to activate all the required roles.&amp;#160; You do this by selecting Control Panel/Programs/Turn Windows features on or off.&amp;#160; from the list you select the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/TKskxOivgzI/AAAAAAAAAls/NH-UzVHAv1Y/s1600-h/Parallels%20Picture%5B2%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Parallels Picture" border="0" alt="Parallels Picture" src="http://lh4.ggpht.com/_r_B45UywYok/TKskyLq89-I/AAAAAAAAAlw/qQdy-ErWxNg/Parallels%20Picture_thumb.png?imgmax=800" width="204" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Doing some configuration&lt;/h3&gt;  &lt;p&gt;Next you should create an Admin Console for you to work with.&amp;#160; Type&amp;#160; “MMC” into the start menu and select File/Add Remove Snap in from the menu.&amp;#160; Select IIS Manager and IIS Manager Ver.6, Also choose Event Log for the current machine. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/TKskzMF4toI/AAAAAAAAAl0/v2K_pYKBIYU/s1600-h/Parallels%20Picture%201%5B2%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Parallels Picture 1" border="0" alt="Parallels Picture 1" src="http://lh4.ggpht.com/_r_B45UywYok/TKskz6pNkDI/AAAAAAAAAl4/9WuIRhFLDIo/Parallels%20Picture%201_thumb.png?imgmax=800" width="244" height="170" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;File Save this to your desktop for later.&lt;/p&gt;  &lt;h3&gt;Getting it working&lt;/h3&gt;  &lt;p&gt;When I got a local copy of the application all the .NET code worked first time without any issue, however when I tried to run any Class ASP code I got a standard Error: This &lt;strong&gt;error (HTTP 500 Internal Server Error) means that the website you are visiting had a server problem which prevented the webpage from displaying.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;After some checking about on the net it turns out that you can turn on messages for ASP code using a configuration setting in IIS Manager,&lt;/p&gt;  &lt;p&gt;Within IIS Manager Browse to the Virtual Directory you need and Double click click on the ASP icon and expand the “Debugging Properties” tree.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/TKsk1XST9fI/AAAAAAAAAl8/qwxEGrP6wYY/s1600-h/Parallels%20Picture%202%5B2%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Parallels Picture 2" border="0" alt="Parallels Picture 2" src="http://lh4.ggpht.com/_r_B45UywYok/TKsk2DaIbJI/AAAAAAAAAmA/kmS-yYihJec/Parallels%20Picture%202_thumb.png?imgmax=800" width="244" height="167" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Turn on “Log Errors to NT Log” and “Send Errors to Browser”.&lt;/p&gt;  &lt;p&gt;Unfortunately after doing this I still did not get an error messages displayed so had to do some more hunting down of the error.&lt;/p&gt;  &lt;h3&gt;Tracing requests&lt;/h3&gt;  &lt;p&gt;You also need to turn on Tracing which can be done by reading the instructions on the following link: &lt;a title="http://learn.iis.net/page.aspx/565/using-failed-request-tracing-to-troubleshoot-classic-asp-errors/" href="http://learn.iis.net/page.aspx/565/using-failed-request-tracing-to-troubleshoot-classic-asp-errors/"&gt;http://learn.iis.net/page.aspx/565/using-failed-request-tracing-to-troubleshoot-classic-asp-errors/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Following this you actually get to see a correct error!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/TKsk34f548I/AAAAAAAAAmE/6j2gh45hO5w/s1600-h/Parallels%20Picture%203%5B2%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Parallels Picture 3" border="0" alt="Parallels Picture 3" src="http://lh3.ggpht.com/_r_B45UywYok/TKsk4qO1JXI/AAAAAAAAAmI/OwLuYtxYzt0/Parallels%20Picture%203_thumb.png?imgmax=800" width="244" height="220" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;LineNumber:21    &lt;br /&gt;ErrorCode:800a01ad     &lt;br /&gt;Description: ActiveX component can't create object&lt;/p&gt;  &lt;p&gt;Checking the global.asa gave me the following line:    &lt;br /&gt;Set GetDirectory = Server.CreateObject(&amp;quot;EnterpriseIreland.BusinessObjects.HumanResources.Directory&amp;quot;)&lt;/p&gt;  &lt;h3&gt;Checking Permissions&lt;/h3&gt;  &lt;p&gt;This error is usually down to permissions or the worker process can’t find the DLL.&amp;#160; Setting “Everyone” with Full permissions on the D:\Applications\ folder did not work, neither did giving “Everyone” access to the D:\Development folder. &lt;/p&gt;  &lt;p&gt;Next I checked to make sure the DLLs were correctly registered by re-running&amp;#160; the “register_assembly.bat” command file located with in the D:\Applications\Common folder.&lt;/p&gt;  &lt;p&gt;Next open Regedit.exe and browse to the DLL that was failing:    &lt;br /&gt;HKEY_CLASSES_ROOT\EnterpriseIreland.BusinessObjects.HumanResources.Directory open the CLSID key and you find a GUID.&amp;#160; In my case it was “{C940B037-A429-303E-8B2E-162E4E19AC91}” search the registry for this GUID.&lt;/p&gt;  &lt;p&gt;You should find it somewhere in the HKEY_CLASSES_ROOT\Wow6432Node\CLSID\ key group; in my case it was here: HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{C940B037-A429-303E-8B2E-162E4E19AC91} click into the “InprocServer32” key and look for the value key “Codebase” this should show the file location of the DLL.&amp;#160; If it’s not pointing to the correct location change it.&lt;/p&gt;  &lt;h3&gt;Moving to App Pool &lt;/h3&gt;  &lt;p&gt;None of these fancy changes seemed to make any difference so I decided to look into the AppPool configuration.&amp;#160; The DefaultAppPool was working fine with .Net, so I created a second one based on this called “ASP”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/TKsk5rgEBpI/AAAAAAAAAmM/Dc7sN525rnc/s1600-h/Parallels%20Picture%5B5%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Parallels Picture" border="0" alt="Parallels Picture" src="http://lh4.ggpht.com/_r_B45UywYok/TKsk6a-XMkI/AAAAAAAAAmQ/WwsSOXUU83g/Parallels%20Picture_thumb%5B1%5D.png?imgmax=800" width="244" height="186" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Next in the Advanced settings you need to make one minor but &lt;strong&gt;VERY IMPORTANT&lt;/strong&gt; change; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/TKsk8FidD_I/AAAAAAAAAmU/U225WSqpWG8/s1600-h/Parallels%20Picture%201%5B5%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Parallels Picture 1" border="0" alt="Parallels Picture 1" src="http://lh4.ggpht.com/_r_B45UywYok/TKsk9f3jf8I/AAAAAAAAAmY/HiRVOy8TuGs/Parallels%20Picture%201_thumb%5B1%5D.png?imgmax=800" width="244" height="160" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You must set “Enable 32-bit Applications” to “True”&lt;/p&gt;  &lt;p&gt;Finally assign your website to use this application pool by selecting it in IIS Manager and click Basic Settings in the Action Menu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/TKsk-66mPZI/AAAAAAAAAmc/DXSmqL96wnw/s1600-h/Parallels%20Picture%202%5B5%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Parallels Picture 2" border="0" alt="Parallels Picture 2" src="http://lh5.ggpht.com/_r_B45UywYok/TKsk_rg3O5I/AAAAAAAAAmg/rS73s1SzZ3I/Parallels%20Picture%202_thumb%5B1%5D.png?imgmax=800" width="244" height="136" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Click Select and choose “ASP” or whatever your AppPool name is called.&lt;/p&gt;  &lt;h3&gt;Success At last!!&lt;/h3&gt;  &lt;p&gt;After all this, we finally have a working legacy ASP site working on Windows 7.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-4407951178606005776?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4407951178606005776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4407951178606005776'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/10/setting-up-windows-7-for-classic-asp.html' title='Setting up Windows 7 for Classic ASP'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/TKskyLq89-I/AAAAAAAAAlw/qQdy-ErWxNg/s72-c/Parallels%20Picture_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-5837305804146418400</id><published>2010-04-05T12:14:00.001-07:00</published><updated>2010-04-05T12:14:29.181-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Adventures when moving to GIT</title><content type='html'>&lt;p&gt;I’ve been on Git hub a few times but never actually set this up on my laptop.&amp;#160; Following some Open Source work with a group of friends I finally got the point to the solution.&amp;#160; Distribution of the repositories and the ability to pick and choose the areas you want to take into your own, was such a simple and effective way to share code I decided to adopt it for most of my local development.&lt;/p&gt;  &lt;p&gt;I am however not the best with the command line interface so when I heard that the tortoise group had got together and created an integrated windows version, I had to give it a go.&lt;/p&gt;  &lt;h3&gt;Setup&lt;/h3&gt;  &lt;p&gt;Download the software from &lt;a href="http://code.google.com/p/tortoisegit/" target="_blank"&gt;Google code&lt;/a&gt; and run the MSI file worked first time without any issue.&amp;#160; You will however need to restart your PC/Laptop following the installation.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S7o2f8CxCPI/AAAAAAAAAk0/DhW9LRlnv7U/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S7o2gUcM3BI/AAAAAAAAAk4/IUfHkfuwmU8/image_thumb.png?imgmax=800" width="244" height="191" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Following an reset you’ll get some extra options in your stadard windows explorer.&lt;/p&gt;  &lt;h3&gt;Connection to an existing repository&lt;/h3&gt;  &lt;p&gt;I already had an existing GitHub repository so it was a simple matter of connecting up to this.&amp;#160; First create a folder on your drive (in my case I called it Development) on your C Drive.&amp;#160; Right click on the empty directory and select Git Clone.&lt;/p&gt;  &lt;p&gt;Select the URL on git hub of the git file and project you want to connect too, in this case the &lt;a href="git://github.com/richardagreene/nxmpp.git" target="_blank"&gt;NXMPP code project&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S7o2giDnW7I/AAAAAAAAAk8/g_egMBuXPIw/s1600-h/image%5B9%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S7o2hLXP_sI/AAAAAAAAAlA/3E5HcqRUbzM/image_thumb%5B3%5D.png?imgmax=800" width="244" height="184" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click Ok.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S7o2hZos9pI/AAAAAAAAAlE/kv0NYdqZygg/s1600-h/image%5B12%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S7o2h83jt4I/AAAAAAAAAlI/RDZXdbF8jMM/image_thumb%5B4%5D.png?imgmax=800" width="244" height="164" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;All going well you can click Close and have a copy of the code on your PC.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S7o2ijpKDBI/AAAAAAAAAlM/rzNcRJ2lnPw/s1600-h/image%5B15%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S7o2i1dvhZI/AAAAAAAAAlQ/ZBlhSm-IvWs/image_thumb%5B5%5D.png?imgmax=800" width="244" height="132" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;Pushing a change&lt;/h3&gt;  &lt;p&gt;So supposing you’ve a change to make to this code, how can you get it back to the cloud repository?&amp;#160; I’ve made a very simple change to one of the tests to illustrate the changes in one file.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S7o2jW9TahI/AAAAAAAAAlU/w5hw4-FsZbM/s1600-h/image%5B18%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S7o2jzsBF1I/AAAAAAAAAlY/QBmCDvori8Q/image_thumb%5B6%5D.png?imgmax=800" width="201" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here in explorer you can see that Git has realised that there was a change to one of the files.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S7o2km_yHkI/AAAAAAAAAlc/ad2r9wqmviw/s1600-h/image%5B21%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S7o2lOo-uPI/AAAAAAAAAlg/rvNW1t4Lk_U/image_thumb%5B7%5D.png?imgmax=800" width="244" height="168" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Right click the file and select “Diff” will bring up the a description of the changes.&lt;/p&gt;  &lt;p&gt;Now lets say that change needs to be placed back into the repository, simply right click the file or directory and select Git Commit.&amp;#160; This will place the code back into the repository.&lt;/p&gt;  &lt;p&gt;I’m looking forward to getting more into this very simple and interesting product.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-5837305804146418400?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/5837305804146418400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/5837305804146418400'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/04/adventures-when-moving-to-git.html' title='Adventures when moving to GIT'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/S7o2gUcM3BI/AAAAAAAAAk4/IUfHkfuwmU8/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-1231248117958160553</id><published>2010-04-01T01:42:00.001-07:00</published><updated>2010-04-01T01:42:43.298-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Resetting the Admin password on a Windows 2003 VM when you forget what it was.</title><content type='html'>&lt;p&gt;Today I had a problem remembering the Administrator password on a VM I had created a long time ago.&amp;#160; Although I had created another Admin level account for myself, the VM was not on the domain so I could not even use my own account.&amp;#160; Luckily some came to my rescue with his magic Linux boot file which can remove the password.&lt;/p&gt;  &lt;h4&gt;Step 1&lt;/h4&gt;  &lt;p&gt;Download the &lt;a href="http://pogostick.net/~pnh/ntpasswd/cd080526.zip" target="_blank"&gt;Offline NT Password &amp;amp; Registry Editor&lt;/a&gt; from their website.&amp;#160; I used version v080526 as v080802 did not seem to be working correctly.&amp;#160; Unzip the ISO file 080526.iso to your local drive.&lt;/p&gt;  &lt;p&gt;Open up the &lt;a href="http://pogostick.net/~pnh/ntpasswd/walkthrough.html" target="_blank"&gt;instructions page&lt;/a&gt; on their site.&lt;/p&gt;  &lt;h4&gt;Step 2&lt;/h4&gt;  &lt;p&gt;Start your VM and mount the ISO file by right clicking on the icon on the bottom left of the screen and selecting “Capture&amp;quot; ISO Image”.&lt;/p&gt;  &lt;p&gt;Now shut down and restart the VM.&lt;/p&gt;  &lt;h4&gt;Step 3&lt;/h4&gt;  &lt;p&gt;At this point you can follow the &lt;a href="http://pogostick.net/~pnh/ntpasswd/walkthrough.html" target="_blank"&gt;instructions page&lt;/a&gt; on the site or just do the following for a quick overview.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Press &amp;lt;Enter&amp;gt; to select the first disk partition &lt;/li&gt;    &lt;li&gt;Press &amp;lt;Enter&amp;gt; to select the default configuration directory &lt;/li&gt;    &lt;li&gt;Press &amp;lt;Enter&amp;gt; to select option 1; “Password Reset”. &lt;/li&gt;    &lt;li&gt;Press &amp;lt;Enter&amp;gt; to select “Edit user data and password” &lt;/li&gt;    &lt;li&gt;Press &amp;lt;Enter&amp;gt; to select the “Administrator” username or enter which ever you wish &lt;/li&gt;    &lt;li&gt;Enter “1” for option “Clear (blank) user password” and press Enter.&amp;#160; There are other options available if needed. &lt;/li&gt;    &lt;li&gt;Enter “!” to quit &lt;/li&gt;    &lt;li&gt;enter “q” to quit &lt;/li&gt;    &lt;li&gt;enter “y” to write the changes to the disk &lt;/li&gt;    &lt;li&gt;Enter “n” to try again option. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Now unmount the ISO by right clicking the icon and selecting “Release 080526.iso” and restart the VM.&amp;#160; You should now be able to login without having a password. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-1231248117958160553?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1231248117958160553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1231248117958160553'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/04/resetting-admin-password-on-windows.html' title='Resetting the Admin password on a Windows 2003 VM when you forget what it was.'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-4545612721399322811</id><published>2010-03-29T15:26:00.001-07:00</published><updated>2010-03-29T15:26:47.221-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>Playing about with REST on .Net</title><content type='html'>&lt;p&gt;I’ve been planning to do more work with Azure and iPhone and figured I should embrace the new wave of developments with &lt;a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" target="_blank"&gt;REST&lt;/a&gt;.&amp;#160; This seems to be the way in which the technology is going even for Microsoft.&amp;#160; I’m a bit of a fan of WCF, so figured I’ve give it a go implementing this using everything I’ve learned from that and with a little help from &lt;a href="http://oreilly.com/catalog/9780596519216" target="_blank"&gt;“RESTful .Net” by Jon Flanders&lt;/a&gt; it worked out well.&lt;/p&gt;  &lt;h3&gt;The Server&lt;/h3&gt;  &lt;p&gt;First step is to create standard VS2010 WCF Service Application project called WCFServer.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S7EpF9ITg8I/AAAAAAAAAkU/edXFg0rMJV0/s1600-h/image%5B2%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S7EpGs4hEjI/AAAAAAAAAkY/-40mi9CylRk/image_thumb.png?imgmax=800" width="244" height="175" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This will give you all the basic items needed to run an IIS Hosted WCF Service.&amp;#160; I won’t go into the details of these to much as I’ll assume you understand the requirement for deleting or renaming the various classes to fit those I’ve used.&lt;/p&gt;  &lt;p&gt;The project will consist of 4 files:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;IRESTService.cs; which is an Interface definition for the server contracts.&lt;/li&gt;    &lt;li&gt;RESTService.svc; the web service definition file&lt;/li&gt;    &lt;li&gt;RESTService.svc.cs; the code behind for the service&lt;/li&gt;    &lt;li&gt;web.config; the application configuration and definition file.&lt;/li&gt; &lt;/ol&gt;  &lt;h4&gt;IRESTService.cs&lt;/h4&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections.Generic;    &lt;br /&gt;using System.Linq;    &lt;br /&gt;using System.Runtime.Serialization;    &lt;br /&gt;using System.ServiceModel;    &lt;br /&gt;using System.ServiceModel.Web;    &lt;br /&gt;using System.Text; &lt;/p&gt;  &lt;p&gt;namespace WCFServer   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [ServiceContract]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public interface IRESTService    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [OperationContract()]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [WebGet(UriTemplate=&amp;quot;/GetRestData/{value}&amp;quot;)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string GetRestData(string value); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [WebGet(UriTemplate = &amp;quot;/&amp;quot;)]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [OperationContract]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string GetRestDataRoot();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;My Service has 2 very simple HTTP GET methods, GetRestDataRoot which will return a simple text string and GetRestData which takes a string and then responds with a string.&amp;#160; These are hardly high tech and are only to illustrate hte process.&lt;/p&gt;  &lt;h4&gt;RESTService.svc&lt;/h4&gt;  &lt;p&gt;&amp;lt;%@ ServiceHost Language=&amp;quot;C#&amp;quot; Debug=&amp;quot;true&amp;quot; Service=&amp;quot;WCFServer.RESTService&amp;quot; CodeBehind=&amp;quot;RESTService.svc.cs&amp;quot; %&amp;gt;&lt;/p&gt;  &lt;p&gt;This defines the service file and the link to the code behind.&lt;/p&gt;  &lt;h4&gt;RESTService.svc&lt;/h4&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections.Generic;    &lt;br /&gt;using System.Linq;    &lt;br /&gt;using System.Runtime.Serialization;    &lt;br /&gt;using System.ServiceModel;    &lt;br /&gt;using System.ServiceModel.Web;    &lt;br /&gt;using System.Text;    &lt;br /&gt;using System.ServiceModel.Activation; &lt;/p&gt;  &lt;p&gt;namespace WCFServer   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class RESTService : IRESTService    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string GetRestData(string value)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return string.Format(&amp;quot;You entered: {0}&amp;quot;, value);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string GetRestDataRoot()   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return string.Format(&amp;quot;Root&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;As you can see from the code behind I’m not really doing anything complicated at this stage, just returning strings.&lt;/p&gt;  &lt;h4&gt;web.config&lt;/h4&gt;  &lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;   &lt;br /&gt;&amp;lt;configuration&amp;gt;&lt;/p&gt;  &lt;p&gt;…………… &amp;lt; sniped &amp;gt; ………&lt;/p&gt;  &lt;p&gt;&amp;lt;httpModules&amp;gt;   &lt;br /&gt;&lt;strong&gt;&amp;#160;&amp;#160; &amp;lt;add name=&amp;quot;NoMoreSVC&amp;quot; type=&amp;quot;WCFServer.RestModule, WCFServer&amp;quot;/&amp;gt;     &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160; &amp;lt;add name=&amp;quot;ScriptModule&amp;quot; type=&amp;quot;System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&amp;quot;/&amp;gt;    &lt;br /&gt; &amp;lt;/httpModules&amp;gt; &lt;/p&gt;  &lt;p&gt;…………… &amp;lt; sniped &amp;gt; ………&lt;/p&gt;  &lt;p&gt;&amp;#160; &amp;lt;system.serviceModel&amp;gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;serviceHostingEnvironment aspNetCompatibilityEnabled=&amp;quot;true&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;services&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;service name=&amp;quot;WCFServer.RESTService&amp;quot; behaviorConfiguration=&amp;quot;WCFServer.RESTServiceBehavior&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;!-- Service Endpoints --&amp;gt;    &lt;br /&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;endpoint address=&amp;quot;&amp;quot; binding=&amp;quot;webHttpBinding&amp;quot; contract=&amp;quot;WCFServer.IRESTService&amp;quot; behaviorConfiguration=&amp;quot;web&amp;quot;&amp;gt;&lt;/strong&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;identity&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;dns value=&amp;quot;localhost&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/identity&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/endpoint&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;endpoint address=&amp;quot;mex&amp;quot; binding=&amp;quot;mexHttpBinding&amp;quot; contract=&amp;quot;IMetadataExchange&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/service&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/services&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;behaviors&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;serviceBehaviors&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;behavior name=&amp;quot;WCFServer.RESTServiceBehavior&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;serviceMetadata httpGetEnabled=&amp;quot;true&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.&amp;#160; Set to false before deployment to avoid disclosing exception information --&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;serviceDebug includeExceptionDetailInFaults=&amp;quot;false&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/behavior&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/serviceBehaviors&amp;gt;    &lt;br /&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;endpointBehaviors&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;behavior name=&amp;quot;web&amp;quot;&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;webHttp/&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/behavior&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/endpointBehaviors&amp;gt;&lt;/strong&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/behaviors&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;/system.serviceModel&amp;gt;    &lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/p&gt;  &lt;p&gt;In the web.config I’ve highlighted some of the more interesting elements for implementing REST.&amp;#160; The endpoint definition has defined the binding as “webHttpBinding&amp;quot; which is needed and we set the behaviorConfiguration to “web&amp;quot;.&amp;#160; The endpointBehaviors is then defined to use webHttp. &lt;/p&gt;  &lt;p&gt;You’ll also notice that I’ve added another called called RestModule and registered this as a httpModule, this was only done to remove the need to access the URL with a .svc on the end.&amp;#160; It’s probably over the top for what I need but it just looked better.&lt;/p&gt;  &lt;h4&gt;restmodule.cs&lt;/h4&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections.Generic;    &lt;br /&gt;using System.Linq;    &lt;br /&gt;using System.Web; &lt;/p&gt;  &lt;p&gt;namespace WCFServer   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class RestModule : IHttpModule    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Dispose()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Init(HttpApplication app)   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; app.BeginRequest += delegate    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; HttpContext ctx = HttpContext.Current;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string path = ctx.Request.AppRelativeCurrentExecutionFilePath;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int i = path.IndexOf('/', 2);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (i &amp;gt; 0)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string svc = path.Substring(0, i) + &amp;quot;.svc&amp;quot;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string rest = path.Substring(i, path.Length - i);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string qs = ctx.Request.QueryString.ToString();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ctx.RewritePath(svc, rest, qs, false);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; };    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Once you have all this up and running we can test it by running the manipulating the URL in my case (&lt;a title="http://localhost:1286/Service1.svc" href="http://localhost:1286/Service1.svc"&gt;http://localhost:1286/Service1.svc&lt;/a&gt;).&amp;#160; If you try to access it via the REST interface you‘ll get the following &lt;a title="http://localhost:1286/Service1.svc" href="http://localhost:1286/Service1/"&gt;http://localhost:1286/Service1/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S7EpHK2AB1I/AAAAAAAAAkc/va_JaL5uUh8/s1600-h/image%5B5%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S7EpHirW6JI/AAAAAAAAAkg/CUvwbkrzye4/image_thumb%5B1%5D.png?imgmax=800" width="244" height="147" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;and &lt;a href="http://localhost:1286/RESTService/GetRestData/Testing123"&gt;http://localhost:1286/RESTService/GetRestData/Testing123&lt;/a&gt; should return the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S7EpIFCTmeI/AAAAAAAAAkk/2yXs9OzCJg0/s1600-h/image%5B8%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S7EpIRfob-I/AAAAAAAAAko/AxO8il21Bpc/image_thumb%5B2%5D.png?imgmax=800" width="244" height="116" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;The Client&lt;/h3&gt;  &lt;p&gt;OK, now we need a client to access the REST server, for this I’ll use a simple UnitTest project.&lt;/p&gt;  &lt;h4&gt;ServiceTest.cs&lt;/h4&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Text;    &lt;br /&gt;using NUnit.Framework;    &lt;br /&gt;using NMock2;    &lt;br /&gt;using System.Data; &lt;/p&gt;  &lt;p&gt;namespace UnitTests   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [TestFixture]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class CompanyObjectTests    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private Mockery _mockSQLDatabse; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [SetUp]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void TestSetup()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; log4net.Config.XmlConfigurator.Configure();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.Info(&amp;quot;Starting up for testing&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [TearDown]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void TestShutDown()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.Info(&amp;quot;Shutting down test&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test(Description = &amp;quot;Test the service&amp;quot;)]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void ServiceTest()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;IClientContract client = new ClientContract();     &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string result = client.GetRestDataRoot();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(result == &amp;quot;Root&amp;quot;, &amp;quot;The result should be 'Root'&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.DebugFormat(&amp;quot;result={0}&amp;quot;, result); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;result = client.GetRestData(&amp;quot;Testing&amp;quot;);     &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(result == &amp;quot;You entered: Testing&amp;quot;, &amp;quot;The result should be 'You entered: Testing'&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.DebugFormat(&amp;quot;result={0}&amp;quot;, result);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Here I’ve created an interface (IClientContract) and a concrete class (ClientContract).&lt;/p&gt;  &lt;h4&gt; IClientContract&lt;/h4&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections.Generic;    &lt;br /&gt;using System.Linq;    &lt;br /&gt;using System.Text;    &lt;br /&gt;using System.ServiceModel;    &lt;br /&gt;using System.ServiceModel.Web; &lt;/p&gt;  &lt;p&gt;namespace UnitTests   &lt;br /&gt;{ &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; [ServiceContract]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public interface IClientContract    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [OperationContract]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [WebGet(    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; BodyStyle = WebMessageBodyStyle.Bare,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ResponseFormat = WebMessageFormat.Xml,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; UriTemplate = &amp;quot;&amp;quot;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; )]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string GetRestDataRoot(); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [OperationContract]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [WebGet(    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; BodyStyle = WebMessageBodyStyle.Bare,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ResponseFormat = WebMessageFormat.Xml,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; UriTemplate = &amp;quot;/GetRestData/{value}&amp;quot;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; )]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string GetRestData(string value);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;}&lt;/p&gt;  &lt;h4&gt;ClientContract&lt;/h4&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections.Generic;    &lt;br /&gt;using System.Linq;    &lt;br /&gt;using System.Text;    &lt;br /&gt;using System.ServiceModel; &lt;/p&gt;  &lt;p&gt;namespace UnitTests   &lt;br /&gt;{ &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public class ClientContract : ClientBase&amp;lt;IClientContract&amp;gt;, IClientContract   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string GetRestDataRoot()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return this.Channel.GetRestDataRoot();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string GetRestData(string symbol)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return this.Channel.GetRestData(symbol);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;}&lt;/p&gt;  &lt;h4&gt;App.config&lt;/h4&gt;  &lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;   &lt;br /&gt;&amp;lt;configuration&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;configSections&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;section name=&amp;quot;log4net&amp;quot; type=&amp;quot;log4net.Config.Log4NetConfigurationSectionHandler, log4net&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;/configSections&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;appSettings&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;add key=&amp;quot;ApplicationName&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;/appSettings&amp;gt; &lt;/p&gt;  &lt;p&gt;&amp;#160; &amp;lt;log4net&amp;gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;appender name=&amp;quot;ConsoleAppender&amp;quot; type=&amp;quot;log4net.Appender.ConsoleAppender&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;layout type=&amp;quot;log4net.Layout.PatternLayout&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;param name=&amp;quot;Header&amp;quot; value=&amp;quot;[Header]\r\n&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;param name=&amp;quot;Footer&amp;quot; value=&amp;quot;[Footer]\r\n&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;param name=&amp;quot;ConversionPattern&amp;quot; value=&amp;quot;%d [%t] %-5p %c %m%n&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/layout&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/appender&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;root&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;level value=&amp;quot;ALL&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;appender-ref ref=&amp;quot;ConsoleAppender&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/root&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;/log4net&amp;gt; &lt;/p&gt;  &lt;p&gt;&amp;#160; &amp;lt;system.serviceModel&amp;gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;bindings /&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;client&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;endpoint address=&amp;quot;&lt;a href="http://localhost:1286/RESTService.svc&amp;quot;"&gt;http://localhost:1286/RESTService.svc&amp;quot;&lt;/a&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; behaviorConfiguration=&amp;quot;rest&amp;quot;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; binding=&amp;quot;webHttpBinding&amp;quot;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; contract=&amp;quot;UnitTests.IClientContract&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/client&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;behaviors&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;endpointBehaviors&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;behavior name=&amp;quot;rest&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;webHttp/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/behavior&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/endpointBehaviors&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/behaviors&amp;gt;&amp;#160; &lt;br /&gt;&amp;#160; &amp;lt;/system.serviceModel&amp;gt;    &lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/p&gt;  &lt;p&gt;Running this in NUnitGUI will give you green lights all the way.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S7EpJNuiUfI/AAAAAAAAAks/Z936onZfXY0/s1600-h/image%5B11%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S7EpJnajr5I/AAAAAAAAAkw/rYtNK1P5qBY/image_thumb%5B3%5D.png?imgmax=800" width="244" height="161" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Source Code&lt;/h3&gt;  &lt;p&gt;All the source code for this project can be &lt;a href="http://cid-7d945804d64f4523.skydrive.live.com/self.aspx/.Public/REST.zip" target="_blank"&gt;found here&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-4545612721399322811?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4545612721399322811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4545612721399322811'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/03/playing-about-with-rest-on-net.html' title='Playing about with REST on .Net'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh5.ggpht.com/_r_B45UywYok/S7EpGs4hEjI/AAAAAAAAAkY/-40mi9CylRk/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2227995990332056019</id><published>2010-03-01T15:16:00.001-08:00</published><updated>2010-03-01T15:16:35.154-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Automating Accessibility testing</title><content type='html'>&lt;p&gt;I’ve been working on new a website recently and one of the major elements is to adhere to &lt;a href="http://www.w3.org/WAI/WCAG1AA-Conformance" target="_blank"&gt;W3C WAI-AA compliant accessibility&lt;/a&gt;. I figured I could just hand the problem over the the designers but taking a Ronald Reagan signature of &lt;a href="http://en.wikipedia.org/wiki/Trust,_but_verify" target="_blank"&gt;“Trust, but verify”&lt;/a&gt; I figured I’d need to check any output regardless. So my question was what would be the easiest way to check a reasonably large website in an automated way so I could be notified if anything was found.&amp;#160; &lt;/p&gt;  &lt;p&gt;To my surprise most of the CMS’s don’t offer this facility out of the box and the online offerings need you to enter a URL on another site each day.&amp;#160; I wanted something simple and free that could be integrated into my existing continuous integration setup with &lt;a href="http://cruisecontrol.sourceforge.net/" target="_blank"&gt;Cruise Control&lt;/a&gt;. I’d already been successful using &lt;a href="http://seleniumhq.org/" target="_blank"&gt;Selenium&lt;/a&gt; and &lt;a href="http://www.nunit.org/index.php" target="_blank"&gt;NUnit&lt;/a&gt; so I figured I could reuse the same technology stack.&amp;#160; But what fun would that be?&amp;#160; So I figured I’d move to using &lt;a href="http://watin.sourceforge.net/" target="_blank"&gt;WatiN&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;The simple solution&lt;/h3&gt;  &lt;p&gt;I ended up with a solution using a combination of three main technologies.&lt;/p&gt;  &lt;p&gt;NUnit – to hold the UnitTesting Code and having all the infrastructure.&lt;/p&gt;  &lt;p&gt;WatiN – to interface with the Browser and get access to the HTML to test.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://tidy.sourceforge.net/" target="_blank"&gt;Tidy&lt;/a&gt; – A very interesting little utility that has all the imbedded accessibility tests that I really did not want to write myself.&lt;/p&gt;  &lt;p&gt;First off you need to create a Unit Test with a continuous integration service environment, for instructions on that you can see my &lt;a href="http://devrichardagreene.blogspot.com/2009/03/building-continuous-integration-server.html" target="_blank"&gt;previous post&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;One off page test&lt;/h3&gt;  &lt;p&gt;Below is a simple UnitTest that will test a HTML page for accessibility errors and warning. I’ve highlighted a number of the more interesting lines.&lt;/p&gt;  &lt;p&gt;using System;    &lt;br /&gt;using System.Collections;     &lt;br /&gt;using System.Collections.Generic;     &lt;br /&gt;using System.Linq;     &lt;br /&gt;using System.Text;     &lt;br /&gt;using NUnit.Framework;     &lt;br /&gt;using Tidy;     &lt;br /&gt;using WatiN.Core; &lt;/p&gt;  &lt;p&gt;namespace HTMLTestExamples    &lt;br /&gt;{ &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; [TestFixture]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class TidyTest     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Tidy.Document _tdoc = new Tidy.Document();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int _status = 0;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;string _ConfigFileName = @&amp;quot;Files\foo.tidy&amp;quot;;&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [TestFixtureSetUp]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void TestFixtureSetup()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;_tdoc.OnMessage += new ITidyDocumentEvents_OnMessageEventHandler(doc_OnMessage);      &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; log4net.Config.XmlConfigurator.Configure();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _status = _tdoc.LoadConfig(_ConfigFileName);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(_status == 0, &amp;quot;Ensure no errors found in configuration&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.Info(&amp;quot;Starting up for testing&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Tests the file.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test]     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void TestHTMLPage()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; String htmlResults = String.Empty;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;using (var browser = new IE(&amp;quot;&lt;/strong&gt;&lt;a href="http://&amp;lt;whatever"&gt;http://&amp;lt;whatever&lt;/a&gt;&lt;strong&gt; URL you want&amp;quot;))      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _status = _tdoc.ParseString(browser.Html);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _status = _tdoc.RunDiagnostics();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(_status == 0, &amp;quot;Oh No!, Error were errors found&amp;quot;);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Process messages from the Tidy parse process.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;level&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;line&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;col&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;message&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void doc_OnMessage(Tidy.TidyReportLevel level, int line, int col, string message)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.InfoFormat(&amp;quot;{3}:&amp;#160; {0}&amp;#160; Line: {1}&amp;#160; Col: {2}&amp;quot;, message, line, col, level);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;The first point of interest is the foo.config file. Tidy can take its configuration setting programmatically or via a config file.&amp;#160; I’ve chosen the config route as it was easier to modify on the fly.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;accessibility-check:&amp;#160; 2      &lt;br /&gt;show-warnings:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; no       &lt;br /&gt;show-errors:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 6&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This file I used only had three setting, &lt;a href="http://www.html-kit.com/docs/tools/tidy/cfg/diagnostics/accessibility_check/" target="_blank"&gt;accessibility-check&lt;/a&gt; is set to 2 which means that it will warn at the level of AA-WAI.&amp;#160;&amp;#160; There are a whole range of different values you can use and these are documented on the &lt;a href="http://www.html-kit.com/docs/tools/tidy/cfg/" target="_blank"&gt;TIDY website&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The next point of interest is how we hook up to the OnMessage event created by Tidy when it reads the HTML pages.&amp;#160; Here we pass the even over to our delegate method called “doc_OnMessage”.&amp;#160; At the moment we simply want to print out the results on screen, but we can expand on this later.&lt;/p&gt;  &lt;p&gt;The next few lines of code do all the real work.   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; using (var browser = new IE(&amp;quot;&amp;lt;URL&amp;gt;&amp;quot;))    &lt;br /&gt;Will tell WatiN to open a browser instance of and load the URL into memory.&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _tdoc.ParseString(browser.Html);    &lt;br /&gt;Will take the raw HTML that has been read from the page and check it for any errors.&amp;#160; This will run basic HTML checks rather than the specific accessibility tests we want to look at, but its important to load the data before we can look the AA.    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _tdoc.RunDiagnostics();    &lt;br /&gt;This is the line is where we actually get to run the tests we are looking to do.&lt;/p&gt;  &lt;p&gt;Running this against my iGoogle page came up with the following:&lt;/p&gt;  &lt;p&gt;***** HTMLTestExamples.TidyTest.TestHTMLPage   &lt;br /&gt;2010-03-01 22:13:26,101 [TestRunnerThread] DEBUG HTMLTestExamples.TidyTest TidyInfo:&amp;#160; Document content looks like HTML Proprietary&amp;#160; Line: 0&amp;#160; Col: 0    &lt;br /&gt;2010-03-01 22:13:26,114 [TestRunnerThread] DEBUG HTMLTestExamples.TidyTest TidyError:&amp;#160; [3.2.1.1]: &amp;lt;doctype&amp;gt; missing.&amp;#160; Line: 1&amp;#160; Col: 1    &lt;br /&gt;2010-03-01 22:13:26,115 [TestRunnerThread] DEBUG HTMLTestExamples.TidyTest TidyError:&amp;#160; [13.2.1.1]: Metadata missing.&amp;#160; Line: 2&amp;#160; Col: 1    &lt;br /&gt;2010-03-01 22:13:26,117 [TestRunnerThread] DEBUG HTMLTestExamples.TidyTest TidyError:&amp;#160; [1.1.10.1]: &amp;lt;script&amp;gt; missing &amp;lt;noscript&amp;gt; section.&amp;#160; Line: 7&amp;#160; Col: 2    &lt;br /&gt;2010-03-01 22:13:26,119 [TestRunnerThread] DEBUG HTMLTestExamples.TidyTest TidyError:&amp;#160; [11.2.1.10]: replace deprecated html &amp;lt;u&amp;gt;.&amp;#160; Line: 9&amp;#160; Col: 745    &lt;br /&gt;2010-03-01 22:13:26,120 [TestRunnerThread] DEBUG HTMLTestExamples.TidyTest TidyError:&amp;#160; [11.2.1.10]: replace deprecated html &amp;lt;u&amp;gt;.&amp;#160; Line: 13&amp;#160; Col: 395    &lt;br /&gt;2010-03-01 22:13:26,121 [TestRunnerThread] DEBUG HTMLTestExamples.TidyTest TidyError:&amp;#160; [1.1.10.1]: &amp;lt;script&amp;gt; missing &amp;lt;noscript&amp;gt; section.&amp;#160; Line: 17&amp;#160; Col: 1&lt;/p&gt;  &lt;p&gt;Humm…. not to good for our friends in Google, butg they can’t be good at everything.&lt;/p&gt;  &lt;h3&gt;One improvement&lt;/h3&gt;  &lt;p&gt;The first thing I did when moving on from the first example was to move away from the hard coded URL.&amp;#160; By simply using the TestCase attribute we are able to add a whole bunch of URLs.&lt;/p&gt;  &lt;p&gt;[Test]   &lt;br /&gt;[TestCase(&amp;quot;&lt;a href="http://www.google.com&amp;quot;)]"&gt;http://www.google.com&amp;quot;)]&lt;/a&gt;    &lt;br /&gt;[TestCase(&amp;quot;&lt;a href="http://www.abc.com&amp;quot;)]"&gt;http://www.abc.com&amp;quot;)]&lt;/a&gt;    &lt;br /&gt;[TestCase(&amp;quot;&lt;a href="http://www.irishtimes.com&amp;quot;)]"&gt;http://www.irishtimes.com&amp;quot;)]&lt;/a&gt;    &lt;br /&gt;public void TestHTMLPage(string url)    &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Tidy.Document tdoc = new Tidy.Document();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; tdoc.OnMessage += new ITidyDocumentEvents_OnMessageEventHandler(doc_OnMessage);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; log4net.Config.XmlConfigurator.Configure();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; _status = tdoc.LoadConfig(_ConfigFileName); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; String htmlResults = String.Empty;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; using (var browser = new IE(url))    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _status = tdoc.ParseString(browser.Html);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _status = tdoc.RunDiagnostics();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(_status == 0, &amp;quot;There were errors found&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; tdoc.OnMessage += new ITidyDocumentEvents_OnMessageEventHandler(doc_OnMessage);    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;One thing I did find is that I had to move the Tidy Document as being defined at the top level to being set at the method. &lt;/p&gt;  &lt;h3&gt;Testing from root to leaf&lt;/h3&gt;  &lt;p&gt;The next thing I did was to setup a simple root to leaf test.&amp;#160; I simply used the built in functionality available in WatiN to build myself a generic list of URLs on the page.&amp;#160; Then store this in a class that I can read back when needed.&lt;/p&gt;  &lt;p&gt;// simple public property to hold all the pages.   &lt;br /&gt;List&amp;lt;Pages&amp;gt; _allPages = new List&amp;lt;Pages&amp;gt;();&amp;#160; &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;/// &amp;lt;summary&amp;gt;   &lt;br /&gt;/// HTML Pages class    &lt;br /&gt;/// &amp;lt;/summary&amp;gt;    &lt;br /&gt;private class Pages    &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public string URL { get; set; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public string Title { get; set; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public ArrayList errors { get; set; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public ArrayList warnings { get; set; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public bool Tested { get; set; }&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;// Use this code within your test   &lt;br /&gt;List&amp;lt;string&amp;gt; pageLinks = ExtractLinks(browser.Links);    &lt;br /&gt;_allPages.Add(currentPage);&amp;#160; &lt;br /&gt;foreach (string link in pageLinks)    &lt;br /&gt; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (!string.IsNullOrEmpty(link) &amp;amp;&amp;amp; !&lt;strong&gt;PageOutsideSite&lt;/strong&gt;(link) &amp;amp;&amp;amp; !&lt;strong&gt;PageAlreadyTested&lt;/strong&gt;(link))    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TestHTMLPage(link);    &lt;br /&gt; }&lt;/p&gt;  &lt;p&gt;// This function will take all the links and build a list   &lt;br /&gt;private List&amp;lt;string&amp;gt; ExtractLinks(LinkCollection linkCollection)    &lt;br /&gt; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;string&amp;gt; links = new List&amp;lt;string&amp;gt;();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (Link link in linkCollection)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; links.Add(link.Url);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return links;    &lt;br /&gt; } &lt;/p&gt;  &lt;p&gt;// Check to see if the page is outside of the main root URL   &lt;br /&gt; private bool PageOutsideSite(string urlRoot, string urlLink)    &lt;br /&gt; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (!urlLink.Contains(urlRoot)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return true;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (urlLink.Contains(&amp;quot;?&amp;quot;))&amp;#160; // ignore param urls    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return true;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (urlLink.Split('/').Length &amp;gt; 5)&amp;#160; // two levels deep    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return true;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return false;    &lt;br /&gt; } &lt;/p&gt;  &lt;p&gt;// Check if the page has already been tested.   &lt;br /&gt; private bool PageAlreadyTested(string urlLink)    &lt;br /&gt; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (Pages page in _allPages)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (page.URL == urlLink &amp;amp;&amp;amp; page.Tested)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return true;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return false;    &lt;br /&gt; }&lt;/p&gt;  &lt;h3&gt;A few words of warning&lt;/h3&gt;  &lt;p&gt;This method of testing is very slow and processor intensive, WatiN is really not the best method for dealing with a large number of pages.&amp;#160; I’d probably recommend some form of download of the files before hand on a nightly basis and then run the Tidy tests.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2227995990332056019?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2227995990332056019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2227995990332056019'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/03/automating-accessibility-testing.html' title='Automating Accessibility testing'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-1957222510035670972</id><published>2010-02-05T12:14:00.000-08:00</published><updated>2010-03-28T13:15:00.820-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Extender Methods in C#</title><content type='html'>&lt;p&gt;Extender Methods were added to the .Net Framework in version 3.0 and allow developers to add additional methods to the current base types.&amp;#160; This is done by using static methods and adding a directive with the extender class type.&lt;/p&gt;  &lt;h3&gt;A simple example&lt;/h3&gt;  &lt;p&gt;You’ve probably seen this in many times in the code where we find the Name of the user from the current Windows security principle.&lt;/p&gt;  &lt;p&gt;string[] strDomainAndUsername = Thread.CurrentPrincipal.Identity.Name.Split('\\');   &lt;br /&gt;Employee employee = employeeSearch.VerifyAccess(strDomainAndUsername[1]); &lt;/p&gt;  &lt;p&gt;Although this works, its not very readable; what extender methods allow is the ability to add new methods to the base .Net types in this case “string”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-4vrHfQcI/AAAAAAAAAkE/8lxBYjxznao/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-4wN01H1I/AAAAAAAAAkI/M4WHc3WKkbk/image_thumb.png?imgmax=800" width="244" height="112" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Normally hitting “.” at the end of the Name attribute will bring up all the methods that relate to whatever that returning type is, in this case a “string”, so you get .Split(), .Contains(), etc.&amp;#160; But with an Extender Method we can add additional ones, for example “.Username()” and “.Domain()” as shown below;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-4wj-Sf8I/AAAAAAAAAkM/309hasK60v8/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-4w2a93YI/AAAAAAAAAkQ/RFVmLVkAmIU/image_thumb1.png?imgmax=800" width="244" height="82" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You know its an Extender Method by the icon next to the name.&lt;/p&gt;  &lt;h3&gt;Implementation&lt;/h3&gt;  &lt;p&gt;To do this you need to create a new class which is a static and a method within that class that is also static and returns the same type of object.&lt;/p&gt;  &lt;p&gt;namespace EnterpriseIreland.Common.Extensions   &lt;br /&gt;{ &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; //Extension methods must be defined in a static class    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public static class StringExtender    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Usernames the specified identity.    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;identity&amp;quot;&amp;gt;The identity.&amp;lt;/param&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;public static string Username(this string identity)&lt;/strong&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string[] networkidentity = identity.Split('\\');    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if(networkidentity.Length &amp;gt;1)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return networkidentity[1];    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return &amp;quot;Unknown&amp;quot;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Domain Name specified by the identity.    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;identity&amp;quot;&amp;gt;The identity.&amp;lt;/param&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;public static string Domain(this string identity)&lt;/strong&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string[] networkidentity = identity.Split('\\');    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if(!String.IsNullOrEmpty(networkidentity[0]))    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return networkidentity[0];    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return &amp;quot;Unknown&amp;quot;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;Now when you want to use it in your own code all you need to do is add the namespace and it should appear for every string. &lt;/p&gt;  &lt;p&gt;using EnterpriseIreland.Common.Extensions;&lt;/p&gt;  &lt;p&gt;Employee employee = employeeSearch.VerifyAccess(&lt;strong&gt;Thread.CurrentPrincipal.Identity.Name.Username()&lt;/strong&gt;);&lt;/p&gt;  &lt;p&gt;Which is far more readable.&amp;#160; Although this is a fairly trivial example you can do fairly complex code functions using this method.&amp;#160; Imagine something like this for Project information put out in a HTML grid format by Year or perhaps generic Currency conversion? &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string projectsToHTMLGrid =&amp;#160; project.FindAllByProperty(“Year”, 2010)&lt;strong&gt;.ToCSSHTMLOutput();&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; double US&amp;#160; =&amp;#160; project.&lt;strong&gt;TotalIncentive.ConvertCurreny(“US”);&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;I’ve set out a standard in the &lt;a href="http://eiportal/sites/it/wiki/Wiki%20Pages/Extender%20Methods.aspx" target="_blank"&gt;Wiki&lt;/a&gt; for doing this type of thing in your projects, feel free to try it out if you see the need.&amp;#160; &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-1957222510035670972?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1957222510035670972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1957222510035670972'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/02/extender-methods-in-c.html' title='Extender Methods in C#'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh5.ggpht.com/_r_B45UywYok/S6-4wN01H1I/AAAAAAAAAkI/M4WHc3WKkbk/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-6280648539666498275</id><published>2010-01-29T15:10:00.001-08:00</published><updated>2010-01-29T15:21:09.596-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Getting Mongo with MongoDB</title><content type='html'>&lt;p&gt;Having a few hours to kill I went off on a tangent and decided to investigate a schema-free, document-oriented database called &lt;a href="http://www.mongodb.org/display/DOCS/Home" target="_blank"&gt;MongoDB&lt;/a&gt;.&amp;#160; The reason was because I’ve heard so much about them on &lt;a href="http://twit.tv/FLOSS" target="_blank"&gt;Floss Weekly&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;Getting it setup&lt;/h3&gt;  &lt;p&gt;First you’ll need the database software which can be downloaded from the &lt;a href="http://www.mongodb.org/display/DOCS/Downloads" target="_blank"&gt;site&lt;/a&gt;. For windows this will bring down a ZIP file which can simply be up packed onto your hard drive.&amp;#160; Create a “data” directory within the MonoDB folder and create a simple batch file called “monodb_start.bat” which starts the server and passed in a location for the database files.&lt;/p&gt;  &lt;p&gt;@echo Off    &lt;br /&gt;echo -----------------------------------------     &lt;br /&gt;echo .&amp;#160;&amp;#160;&amp;#160; Starting the MongoDB instance     &lt;br /&gt;echo -----------------------------------------     &lt;br /&gt;.\bin\mongod --dbpath=./data&lt;/p&gt;  &lt;p&gt;From the command line just type “mongodb_start” and you should get a command window appear.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S2Nq0E3VZII/AAAAAAAAAQ0/u5INL8BKcNE/s1600-h/image%5B2%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S2Nq0jNb4LI/AAAAAAAAAQ4/BEiqZCjJEKw/image_thumb.png?imgmax=800" width="244" height="125" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The next step is to get the Database Driver for C#.&amp;#160; I’ve found the one listed on the site worked fine.&amp;#160; You can get this from &lt;a href="http://github.com/samus/mongodb-csharp" target="_blank"&gt;Git Hub&lt;/a&gt; and click the Download Source link in the top right of the screen.&amp;#160; Once you get the Source open it in Visual Studio and compile the project to give you “MongoDB.Driver.dll”.&lt;/p&gt;  &lt;p&gt;Finally you’ll need something that will read the JSON which is exported from database queries.&amp;#160; You can get a good &lt;a href="http://www.codeplex.com/Json" target="_blank"&gt;Json.NET library&lt;/a&gt; from codeplex. Again download the ZIP file and extract the version you require.&lt;/p&gt;  &lt;h3&gt;Creating a project and query the database&lt;/h3&gt;  &lt;p&gt;Open up a new solution in Visual Studio and create a new class library called “mongoTest”.&amp;#160; I’m going to create an NUnit project which will allow us to do basic queries.&amp;#160; Add the references you’re going to need; MongoDB.Driver, Newtonsoft.Json, nunit.framework and log4net.&lt;/p&gt;  &lt;p&gt;Now create a new class file called “DevelopmentAdvisors” which has the following code:&lt;/p&gt;  &lt;p&gt;using System;    &lt;br /&gt;using System.Collections.Generic;     &lt;br /&gt;using System.Linq;     &lt;br /&gt;using System.Text;     &lt;br /&gt;using NUnit.Framework;     &lt;br /&gt;using MongoDB.Driver;     &lt;br /&gt;using Newtonsoft.Json; &lt;/p&gt;  &lt;p&gt;namespace mongoTest    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [TestFixture]     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class DevelopmentAdvisors     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; { &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Database _mongoDB = null;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMongoCollection _daCollection = null; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [TestFixtureSetUp]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void mongo_SetupDatabase()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; log4net.Config.XmlConfigurator.Configure();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var mongo = new Mongo();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; mongo.Connect();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _mongoDB = mongo.getDB(&amp;quot;MyDB&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _daCollection = _mongoDB.GetCollection(&amp;quot;DevelopmentAdvisors&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;This code will allow us to connect to a database called “MyDB” and connect to a “collection” (or table in any normal db) called “DevelopmentAdvisors”.&lt;/p&gt;  &lt;p&gt;You’ll also need to create an App.config file so you can get the output. the contents of that is shown below:&lt;/p&gt;  &lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;    &lt;br /&gt;&amp;lt;configuration&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;configSections&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;section name=&amp;quot;log4net&amp;quot; type=&amp;quot;log4net.Config.Log4NetConfigurationSectionHandler, log4net&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;/configSections&amp;gt; &lt;/p&gt;  &lt;p&gt;&amp;#160; &amp;lt;log4net&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;appender name=&amp;quot;ConsoleAppender&amp;quot; type=&amp;quot;log4net.Appender.ConsoleAppender&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;layout type=&amp;quot;log4net.Layout.PatternLayout&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;param name=&amp;quot;Header&amp;quot; value=&amp;quot;[Header]\r\n&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;param name=&amp;quot;Footer&amp;quot; value=&amp;quot;[Footer]\r\n&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;param name=&amp;quot;ConversionPattern&amp;quot; value=&amp;quot;%d [%t] %-5p %c %m%n&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/layout&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/appender&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;root&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;level value=&amp;quot;Debug&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;appender-ref ref=&amp;quot;ConsoleAppender&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/root&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;/log4net&amp;gt; &lt;/p&gt;  &lt;p&gt;&amp;lt;/configuration&amp;gt;&lt;/p&gt;  &lt;p&gt;Now that al the basic setups are out of the way we can do our first inserts.&lt;/p&gt;  &lt;p&gt;[Test(Description=&amp;quot;Insert a bunch of random record&amp;quot;)]    &lt;br /&gt;[TestCase(&amp;quot;Joe&amp;quot;, &amp;quot;Smith&amp;quot;, null, null)]     &lt;br /&gt;[TestCase(&amp;quot;Joe&amp;quot;, &amp;quot;Murphy&amp;quot;, &amp;quot;Mr.&amp;quot;, null)]     &lt;br /&gt;[TestCase(&amp;quot;Paddy&amp;quot;, &amp;quot;O'Brien&amp;quot;, &amp;quot;Mr.&amp;quot;, &amp;quot;Dublin&amp;quot;)]     &lt;br /&gt;[TestCase(&amp;quot;Fred&amp;quot;, &amp;quot;Smith&amp;quot;, &amp;quot;Mr.&amp;quot;, &amp;quot;Eastwall, Dublin&amp;quot;)]     &lt;br /&gt;[TestCase(null, &amp;quot;Martin&amp;quot;, &amp;quot;Miss.&amp;quot;, &amp;quot;Carlow&amp;quot;)]     &lt;br /&gt;public void mongoTest_InsertNewDA(string firstName, string secondName, string title, string address)     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Document da = new Document();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if(!String.IsNullOrEmpty(firstName))     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; da[&amp;quot;FirstName&amp;quot;] = firstName;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if(!String.IsNullOrEmpty(secondName))     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; da[&amp;quot;SecondName&amp;quot;] = secondName;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if(!String.IsNullOrEmpty(title))     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; da[&amp;quot;Title&amp;quot;] = title;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if(!String.IsNullOrEmpty(address))     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; da[&amp;quot;Address&amp;quot;] = address;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; _daCollection.Insert(da);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // find if the records were added     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ICursor cursor = _daCollection.FindAll();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(cursor.Documents.Count() &amp;gt; 0, &amp;quot;No records found&amp;quot;);     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Ok, here we go starting the project using NUnit GUI will give us the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S2Nq1O72YhI/AAAAAAAAAQ8/VKzwNXg9Axo/s1600-h/image%5B5%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S2Nq1a0Y9II/AAAAAAAAARA/21EMFasFwdA/image_thumb%5B1%5D.png?imgmax=800" width="244" height="121" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click Run and we should get a bunch of Green lights!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S2Nq1yeNhJI/AAAAAAAAARE/1Q-zXAwZqiw/s1600-h/image%5B8%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S2Nq2oVaYDI/AAAAAAAAARI/KQW8zH-w_uE/image_thumb%5B2%5D.png?imgmax=800" width="244" height="120" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you notice your MongoDB command window now has a new connection listed.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S2Nq3IFIl0I/AAAAAAAAARM/W4DfEbbD4vo/s1600-h/image%5B11%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S2Nq30DMihI/AAAAAAAAARQ/e7dwQP_8st4/image_thumb%5B3%5D.png?imgmax=800" width="244" height="125" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;OK so that inserts records with different layouts into the collection. But there is no point in doing this if we can get the data out so we create a new test.&amp;#160; Using the code below we use the built in function called &lt;strong&gt;FindAll()&lt;/strong&gt; to extract all the information from the database.&lt;/p&gt;  &lt;p&gt;[Test(Description = &amp;quot;Search collection for results&amp;quot;)]    &lt;br /&gt;public void mongoTest_SearchForResults()     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ICursor cursor = &lt;strong&gt;_daCollection.FindAll();&lt;/strong&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(cursor.Documents.Count() &amp;gt; 0, &amp;quot;No values found!&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; foreach (Document doc in cursor.Documents)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.DebugFormat(&amp;quot;Record {0};&amp;quot;, doc.ToString());     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Clicking run will present the records we’ve added in the last run.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S2Nq4Xh4snI/AAAAAAAAARU/w1oISQElG4Y/s1600-h/image%5B14%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S2Nq47No96I/AAAAAAAAARY/zmGbGJukAhk/image_thumb%5B4%5D.png?imgmax=800" width="244" height="126" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The console shows that the database is returning JSON strings for each record item. &lt;/p&gt;  &lt;h3&gt;Lets get more professional with this&lt;/h3&gt;  &lt;p&gt;Dealing with Document and var objects is not really good enough to deal with when we code, so the best thing to do it create a class which holds that information.&amp;#160; Create a new class called “DAClass” and paste in the following code:&lt;/p&gt;  &lt;p&gt;using System;    &lt;br /&gt;using System.Collections.Generic;     &lt;br /&gt;using System.Linq;     &lt;br /&gt;using System.Text;     &lt;br /&gt;using MongoDB.Driver;     &lt;br /&gt;using Newtonsoft.Json;     &lt;br /&gt;using mongoTest.ExtensionMethods; &lt;/p&gt;  &lt;p&gt;namespace mongoTest    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// Interface for the Entity     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public interface IMongoEntity     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Document InternalDocument { get; set; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// Class holding the DA information     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; sealed class DAClass : IMongoEntity     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the first name.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;value&amp;gt;The first name.&amp;lt;/value&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string FirstName     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return InternalDocument.Field(&amp;quot;FirstName&amp;quot;); }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { InternalDocument[&amp;quot;FirstName&amp;quot;] = value; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the name of the second.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;value&amp;gt;The name of the second.&amp;lt;/value&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string SecondName     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return InternalDocument.Field(&amp;quot;SecondName&amp;quot;); }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { InternalDocument[&amp;quot;SecondName&amp;quot;] = value; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the title.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;value&amp;gt;The title.&amp;lt;/value&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string Title     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return InternalDocument.Field(&amp;quot;Title&amp;quot;); }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { InternalDocument[&amp;quot;Title&amp;quot;] = value; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the address.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;value&amp;gt;The address.&amp;lt;/value&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string Address     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return InternalDocument.Field(&amp;quot;Address&amp;quot;); }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { InternalDocument[&amp;quot;Address&amp;quot;] = value; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets the list of items     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;typeparam name=&amp;quot;TDocument&amp;quot;&amp;gt;The type of the document.&amp;lt;/typeparam&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;whereClause&amp;quot;&amp;gt;The where clause.&amp;lt;/param&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;fromCollection&amp;quot;&amp;gt;From collection.&amp;lt;/param&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static IList&amp;lt;TDocument&amp;gt; GetListOf&amp;lt;TDocument&amp;gt;(Document whereClause, IMongoCollection fromCollection) where TDocument : IMongoEntity     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var docs = fromCollection.Find(whereClause).Documents;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return DocsToCollection&amp;lt;TDocument&amp;gt;(docs);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Documents to collection.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;typeparam name=&amp;quot;TDocument&amp;quot;&amp;gt;The type of the document.&amp;lt;/typeparam&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;documents&amp;quot;&amp;gt;The documents.&amp;lt;/param&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static IList&amp;lt;TDocument&amp;gt; DocsToCollection&amp;lt;TDocument&amp;gt;(IEnumerable&amp;lt;Document&amp;gt; documents) where TDocument : IMongoEntity     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var list = new List&amp;lt;TDocument&amp;gt;();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var settings = new JsonSerializerSettings();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (var document in documents)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var docType = Activator.CreateInstance&amp;lt;TDocument&amp;gt;();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; docType.InternalDocument = document;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list.Add(docType);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return list;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the internal document.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;value&amp;gt;The internal document.&amp;lt;/value&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public Document InternalDocument { get; set; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Here we have a property for each data item, which is generated from the JSON Document string.&amp;#160; Here I’ve added a new extension method to the Document type called “Field” which gets round the problem of having nulls in the dataset as a plain old ToString() will crash out.&amp;#160; The extension method is simply a new class file called “DocumentExtensions” and paste in the following code.&lt;/p&gt;  &lt;p&gt;using System;    &lt;br /&gt;using System.Collections.Generic;     &lt;br /&gt;using System.Linq;     &lt;br /&gt;using System.Text;     &lt;br /&gt;using MongoDB.Driver; &lt;/p&gt;  &lt;p&gt;namespace mongoTest.ExtensionMethods    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //Extension methods must be defined in a static class     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static class DocumentExtensions     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Fields the specified in the document being passed     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;doc&amp;quot;&amp;gt;The document&amp;lt;/param&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;fieldName&amp;quot;&amp;gt;Name of the field to be found&amp;lt;/param&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static string Field(this Document doc, string fieldName)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return (doc[fieldName] == null ? null : doc[fieldName].ToString());     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Now back in our DevelopmentAdvisors class file we’re going to do some searching.&lt;/p&gt;  &lt;p&gt;[Test(Description = &amp;quot;Search the da records for results&amp;quot;)]    &lt;br /&gt;private void mongoTest_SearchForOneDA()     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Document spec = new Document();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; spec[&amp;quot;Title&amp;quot;] = &amp;quot;Mr.&amp;quot;;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; IList&amp;lt;DAClass&amp;gt; das = DAClass.GetListOf&amp;lt;DAClass&amp;gt;(spec, _daCollection);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(das.Count &amp;gt; 0, &amp;quot;No values found!&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; _log.DebugFormat(&amp;quot;Name: {0} {1}&amp;quot;, das[0].FirstName, das[0].SecondName);     &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;This method will find all DA’s with a title of “Mr.” and return that information into the IList.&lt;/p&gt;  &lt;p&gt;Finally here is a method that uses a bit of Linq to order the results.&lt;/p&gt;  &lt;p&gt;[Test(Description = &amp;quot;Use Linq query&amp;quot;)]    &lt;br /&gt;private void mongoTest_SearchForAllDAsAndOrder()     &lt;br /&gt;{&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160; ICursor cursor = _daCollection.FindAll();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var orderedList = from da in DAClass.DocsToCollection&amp;lt;DAClass&amp;gt;(cursor.Documents)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; orderby da.SecondName     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; select da;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; foreach (DAClass da in orderedList)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.DebugFormat(&amp;quot;Name: {0} {1}&amp;quot;, da.FirstName, da.SecondName);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(cursor.Documents.Count() &amp;gt; 0, &amp;quot;No records in collection!&amp;quot;);     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;The source code is &lt;a href="http://cid-7d945804d64f4523.skydrive.live.com/self.aspx/.Public/mongoTest.zip" target="_blank"&gt;available here&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-6280648539666498275?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6280648539666498275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6280648539666498275'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/01/getting-mongo-with-mongodb.html' title='Getting Mongo with MongoDB'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh5.ggpht.com/_r_B45UywYok/S2Nq0jNb4LI/AAAAAAAAAQ4/BEiqZCjJEKw/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-1567332623108492044</id><published>2010-01-29T10:11:00.001-08:00</published><updated>2010-01-29T10:11:56.274-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Going “Old school” posting ASP.NET to ASP pages</title><content type='html'>&lt;p&gt;Today I had an interesting problem, how can you get a Form post from ASP.NET to classic ASP?&amp;#160; At first this would seem to be a simple thing, just use Server.Transfer, well as I discovered you can’t do that.&lt;/p&gt;  &lt;p&gt;Here is some example code:&lt;/p&gt;  &lt;h3&gt;default.aspx&lt;/h3&gt;  &lt;p&gt;&amp;lt;body&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:TextBox ID=&amp;quot;send_this&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;asp:Button ID=&amp;quot;send&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; runat=&amp;quot;server&amp;quot; Text=&amp;quot;send&amp;quot; onclick=&amp;quot;send_Click&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/div&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/form&amp;gt;     &lt;br /&gt;&amp;lt;/body&amp;gt;&lt;/p&gt;  &lt;h3&gt;default.aspx.cs&lt;/h3&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; protected void send_Click(object sender, EventArgs e)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Server.Transfer(&amp;quot;receive.asp&amp;quot;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;receive.asp&lt;/h3&gt;  &lt;p&gt;&amp;lt;body&amp;gt;    &lt;br /&gt;Got: &amp;lt;%=Request.Form(&amp;quot;send_this&amp;quot;)%&amp;gt;     &lt;br /&gt;&amp;lt;/body&amp;gt;&lt;/p&gt;  &lt;p&gt;Will return you an &lt;strong&gt;“Error executing child request for receive.asp”&lt;/strong&gt; error.&amp;#160; Checking with &lt;a href="http://support.microsoft.com/kb/320439" target="_blank"&gt;Microsoft&lt;/a&gt; it turned out that this is by design.&lt;/p&gt;  &lt;p&gt;Request.Redirect was no good, as it won’t send any information over HTTP and playing around the HTTP streams was fun but again would not pass control over to the other page.&lt;/p&gt;  &lt;h2&gt;One possible solution&lt;/h2&gt;  &lt;p&gt;The solution you can use is to capture the information on the way into your ASP.NET code and using JavaScript redirect the post to the other page.&amp;#160; First you will need to add the page body to ASP.NET by adding and id and runat=“server”. &lt;/p&gt;  &lt;p&gt;&amp;lt;body&lt;strong&gt; id=&amp;quot;body1&amp;quot; runat=&amp;quot;server&amp;quot;&lt;/strong&gt;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;div&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:TextBox ID=&amp;quot;send_this&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;asp:Button ID=&amp;quot;send&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; runat=&amp;quot;server&amp;quot; Text=&amp;quot;send&amp;quot; onclick=&amp;quot;send_Click&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/div&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/form&amp;gt;     &lt;br /&gt;&amp;lt;/body&amp;gt;&lt;/p&gt;  &lt;p&gt;Then in the ASP.NET code behind inject some javascript and an action method to your form.&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; protected void send_Click(object sender, EventArgs e)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; form1.Action=&amp;quot;receive.asp&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; form1.Method = &amp;quot;post&amp;quot;;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; body1.Attributes[&amp;quot;onload&amp;quot;] = &amp;quot;document.forms[0].submit();&amp;quot;;       &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;This will give you the best of both worlds… ability to use all ASP.NET controls on the main page and then post the values to classic ASP.&amp;#160; I can’t wait for the day there won’t be any need to use classic ASP again!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-1567332623108492044?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1567332623108492044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1567332623108492044'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/01/going-old-school-posting-aspnet-to-asp.html' title='Going “Old school” posting ASP.NET to ASP pages'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-3596513711315876792</id><published>2010-01-21T12:13:00.000-08:00</published><updated>2010-03-28T13:13:09.352-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>Approval blogging permission</title><content type='html'>&lt;p&gt;Had a problem today with permissions on a SharePoint Blog, by default blogs by contributors need to be approved by the Owner before being published.&amp;#160; This is a bit of a pain for Users, especially seeing that it’s only a small number of contributors anyway.&amp;#160; So to remove this open the “Posts” list, and select Settings/List Settings. Click Version Settings and the first option is “Content Approval”.&amp;#160; Set this to “No”.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-3596513711315876792?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/3596513711315876792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/3596513711315876792'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/01/approval-blogging-permission_21.html' title='Approval blogging permission'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-5446807291292729151</id><published>2010-01-15T12:11:00.000-08:00</published><updated>2010-03-28T13:12:25.655-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>Modifying a Sharepoint Master page</title><content type='html'>&lt;p&gt;We had a request to change some of the base layouts of a Sharepoint publishing site today, which turned out to be a lot easier than first expected.&amp;#160; the requirement was to remove the Search feature from the home page.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-4EWJU62I/AAAAAAAAAjM/1Qwv-4-QPGM/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-4EjZ1R0I/AAAAAAAAAjQ/RMOCQ8midvY/image_thumb1.png?imgmax=800" width="244" height="103" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;First off I figured I’d need to find some setting for the site but there were none obvious that control this area.&amp;#160; I was just about the modify the code on the server when it occurred to me that this is probably something in the Master Page that can be changed.&lt;/p&gt;  &lt;h3&gt;Changing a Sharepoint Master Page&lt;/h3&gt;  &lt;p&gt;First off you need to find out which master page your site is using, do this by going to Site Settings/Master Page.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-4FGw-oII/AAAAAAAAAjU/vF7lxRpQbJA/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-4FXIMjFI/AAAAAAAAAjY/hqqgF4ULjt8/image_thumb2.png?imgmax=800" width="244" height="110" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here you can see that the “default.master” is being served up.&lt;/p&gt;  &lt;p&gt;Next we need to get a copy of that page so we can make the changes.&amp;#160; Do this by going to the “Site Settings/Master pages and page layouts” option and download a copy of the master file.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-4FhcwmkI/AAAAAAAAAjc/b7h5JJNGTr4/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-4GFWSkwI/AAAAAAAAAjg/WXPngc6Yxm0/image_thumb3.png?imgmax=800" width="244" height="129" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Edit this file being sure to keep the placeholders in the correct place as these are needed by Sharepoint.&amp;#160; In this case I wanted to remove the User control that displayed the search box.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-4Gmdha_I/AAAAAAAAAjk/YtCp6iDmjnw/s1600-h/image14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-4HMERVoI/AAAAAAAAAjo/qk6VNCQaNRc/image_thumb4.png?imgmax=800" width="244" height="65" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;becomes:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-4HvdYZ3I/AAAAAAAAAjs/Qvz-yse-nvs/s1600-h/image17.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-4H06jOII/AAAAAAAAAjw/eAsD5jyjgww/image_thumb5.png?imgmax=800" width="244" height="45" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Next you upload the new file under a different name, check it in and then approve it.&amp;#160; Once you have completed this task it will be made available in the Site Settings/Master list for selection.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-4ItuEQ0I/AAAAAAAAAj0/zsUNQWy6oLw/s1600-h/image20.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-4JJiCQPI/AAAAAAAAAj4/k4-8RAhGWo8/image_thumb6.png?imgmax=800" width="244" height="221" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;select this and click Ok.&amp;#160; Refresh the home page and the search box has now been removed.&amp;#160; The really good thing about this is that now we know how we can change the entire layout of a sharepoint page, basically everything can be modified as long as the content placeholders are left in your Masterpage.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-4JX2KNeI/AAAAAAAAAj8/OUXh92w9ZNk/s1600-h/image23.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-4KDUXTKI/AAAAAAAAAkA/t616LXEweTc/image_thumb7.png?imgmax=800" width="244" height="120" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-5446807291292729151?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/5446807291292729151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/5446807291292729151'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/01/modifying-sharepoint-master-page.html' title='Modifying a Sharepoint Master page'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh3.ggpht.com/_r_B45UywYok/S6-4EjZ1R0I/AAAAAAAAAjQ/RMOCQ8midvY/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-4544379724052084069</id><published>2009-12-17T12:10:00.000-08:00</published><updated>2010-03-28T13:10:44.756-07:00</updated><title type='text'>Overlapping dates</title><content type='html'>&lt;p&gt;Had an interesting problem a few nights ago which at first seemed like a really easy thing, but turned out to be a right pain in the face.&amp;#160; I figured I’d do a blog on it as it might help someone else later on.&lt;/p&gt;  &lt;h3&gt;A Simple Problem .. not !!&lt;/h3&gt;  &lt;p&gt;What I wanted to figure out was if two date ranges overlapped.&amp;#160; the logic of this was a lot harder to get my head around than I first expected.&amp;#160; As I was dealing with a range rather than static dates any of the existing DateTime functions were useless, also working with TimeSpans I find difficult.&amp;#160; The solution was to create a good Test case and keep playing around with the logic.&lt;/p&gt;  &lt;p&gt;[Test(Description=&amp;quot;Test over lapping dates&amp;quot;)]   &lt;br /&gt;[TestCase(&amp;quot;2009-12-17 13:00:00&amp;quot;, &amp;quot;2009-12-17 17:00:00&amp;quot;, &amp;quot;2009-12-17 13:00:00&amp;quot;, &amp;quot;2009-12-17 13:00:00&amp;quot;, true)]    &lt;br /&gt;[TestCase(&amp;quot;2009-12-17 13:00:00&amp;quot;, &amp;quot;2009-12-17 13:30:00&amp;quot;, &amp;quot;2009-12-17 14:00:00&amp;quot;, &amp;quot;2009-12-17 14:30:00&amp;quot;, false)]    &lt;br /&gt;public void CompareDatesTest(string firstStartDate, string firstEndDate, string secondStartDate, string secondEndDate, bool expectedOverlap)    &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DateTime first_start_date = DateTime.Parse(firstStartDate);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DateTime first_end_date = DateTime.Parse(firstEndDate);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DateTime second_start_date = DateTime.Parse(secondStartDate);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DateTime second_end_date = DateTime.Parse(secondEndDate);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //Compare    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(DatesOverlap(first_start_date, first_end_date, second_start_date, second_end_date) == expectedOverlap, &amp;quot;booking overlap validation did not work&amp;quot;);    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;the test case above will run two dates through my logic and return True if the first and second date rages overlap, False if they don’t. &lt;/p&gt;  &lt;h3&gt;My magic function&lt;/h3&gt;  &lt;p&gt;To work out the problem I had to convert the dates into Ticks.&amp;#160; This converts the date in the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001.&amp;#160; Using that conversion I can easily use the numerical Great-than Boolean functions…. so after much playing around with IF statements I came up with: &lt;/p&gt;  &lt;p&gt;private bool DatesOverlap(DateTime firstStart, DateTime firstEnd, DateTime secondStart, DateTime secondEnd)   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return &lt;strong&gt;(firstEnd.Ticks &amp;gt;= secondStart.Ticks) &amp;amp;&amp;amp; (secondEnd.Ticks &amp;gt;= firstStart.Ticks);&lt;/strong&gt;    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;After doing all this I then did a quick Google to find someone had come up with the same solution.&amp;#160; D’oh!.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-4544379724052084069?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4544379724052084069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4544379724052084069'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/12/overlapping-dates.html' title='Overlapping dates'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2441528619246910769</id><published>2009-12-11T12:09:00.000-08:00</published><updated>2010-03-28T13:09:37.547-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Reflecting Classes and content</title><content type='html'>&lt;p&gt;Yesterday someone asked for a way to print out all the contents of a class including the values that were current assigned.&amp;#160; This initially seemed like an easy thing to do, but turned out to be a little more complicated that expected.&lt;/p&gt;  &lt;h2&gt;The Easy Way&lt;/h2&gt;  &lt;p&gt;First thing we need to understand about .NET classes is that they are all inherited from a base type called Object.&amp;#160; This base object has a handy little method called ToString(), which will return you a string representation of that object.&amp;#160; You would have used this dozens of times in your code.&lt;/p&gt;  &lt;p&gt;int X = 32;   &lt;br /&gt;Console.WriteLine(&amp;quot;The value of X is:” + X.ToString());&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-3dULsgGI/AAAAAAAAAis/lcpLzXoXRAE/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-3dhT26hI/AAAAAAAAAiw/qJIFxBlAbos/image_thumb.png?imgmax=800" width="244" height="168" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This returns “The value of X is:32” which is fine for simple objects like int, float, DateTime but what about our custom classes?.&amp;#160; If you coded up something like the following:&lt;/p&gt;  &lt;p&gt;public class SomeObject   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public string Firstname { get; set; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public string Surname { get; set; }    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;Now you’re test code would look like this: &lt;/p&gt;  &lt;p&gt;SomeObject someObject = new SomeObject();   &lt;br /&gt;someObject.Firstname = &amp;quot;Tiberius&amp;quot;;    &lt;br /&gt;someObject.Surname = &amp;quot;Percinus&amp;quot;;    &lt;br /&gt;Console.WriteLine(&amp;quot;The value of someObjectis: &amp;quot; + someObject.ToString()); &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-3d7fIrVI/AAAAAAAAAi0/5t-ktb6r_z8/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-3ec1E9NI/AAAAAAAAAi4/JLPG3WTVHoQ/image_thumb2.png?imgmax=800" width="244" height="181" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This returns “The value of someObject is: UnitTests.ReflectionExample.SomeObject” which is not really helpful at all.&amp;#160; The normal way around this is to create an override on the ToString() method which returns a more meaningful result.&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public class SomeObject   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string Firstname { get; set; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string Surname { get; set; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Local implementation of ToString based on class members    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;    &lt;br /&gt;&amp;#160; &lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public override String ToString()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; StringBuilder sbuffer = new StringBuilder();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sbuffer.Append(&amp;quot;{&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sbuffer.AppendFormat(&amp;quot;Firstname = {0}, &amp;quot;, this.Firstname);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sbuffer.AppendFormat(&amp;quot;Surname = {0}, &amp;quot;, this.Surname);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sbuffer.Append(&amp;quot; }&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return sbuffer.ToString();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;With this we create a large string with all of the local values returned in a meaningful way. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-3ejn7EtI/AAAAAAAAAi8/R70D5EfKAAY/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-3fRlzKxI/AAAAAAAAAjA/n6O2MBRDOaY/image_thumb3.png?imgmax=800" width="244" height="154" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;This returns: “The value of someObject is: {Firstname = Tiberius, Surname = Percinus,&amp;#160; }”.&lt;/p&gt;  &lt;h2&gt;The Fancy Way &lt;/h2&gt;  &lt;p&gt;“OK”, I was told, “But this object has only two data items what happens if I’ve got 180?”.&amp;#160; Which is a very valid question.&amp;#160; The best answer to this is to use a technique called “Reflection” which allows you to crack open a class to access its values.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160; using System.Reflection;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/strong&gt;public class SomeObject    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string Firstname { get; set; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string Surname { get; set; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //&amp;#160; ……&amp;#160; assume another 180 properties are here ……&amp;#160; //    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string LastProperty { get; set; }&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Local implementation of ToString based on reflection    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public override String ToString()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; StringBuilder sbuffer = new StringBuilder();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sbuffer.Append(&amp;quot;{&amp;quot;);     &lt;br /&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; PropertyInfo[] properties = this.GetType().GetProperties();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (PropertyInfo prop in properties)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sbuffer.AppendFormat(&amp;quot;{0} = {1}, &amp;quot;, prop.Name, prop.GetValue(this, null));      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sbuffer.Append(&amp;quot; }&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return sbuffer.ToString();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;Using the foreach loop and the GetType().GetProperties() methods we get an array of all properties in the class.&amp;#160; Then we just have string builder join them all together. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-3fkR1FOI/AAAAAAAAAjE/XbtMTkS-nOA/s1600-h/image14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-3gNPzufI/AAAAAAAAAjI/1i5UFUOLH94/image_thumb4.png?imgmax=800" width="244" height="219" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This will now return: “The value of someObject is: {Firstname = Tiberius, Surname = Percinus, … and on for all the properties … , LastProperty = ,&amp;#160; }”. &lt;/p&gt;  &lt;p&gt;So why not do this all the time? Well the simple reason is that reflection adds a little more load on the processor, so for the majority of cases it’s best to stick to “the easy way”, unless you have a very, very large set of properties. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2441528619246910769?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2441528619246910769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2441528619246910769'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/12/reflecting-classes-and-content.html' title='Reflecting Classes and content'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/S6-3dhT26hI/AAAAAAAAAiw/qJIFxBlAbos/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-8864066066843937956</id><published>2009-12-08T12:08:00.000-08:00</published><updated>2010-03-28T13:08:20.354-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>Conditional Pre-Complication is good for what ails you.</title><content type='html'>&lt;p&gt;Recently found a comments in the code base that stated &amp;quot;Remove on Live!&amp;quot; in the description.&amp;#160; It was perfectly valid code, but unfortunately but there was no way any developer (other than the person who wrote it in the first place) will remove the code before compiling.&amp;#160; The good news is that there is a solution to this problem and that’s &amp;quot;Conditional Pre-Compilation Symbols&amp;quot;.&amp;#160; That all sounds very complicated but its really simple.&amp;#160; It means you can mark a section of code, so that it is placed within a specific assembly. &lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Simple Conditional Pre-Complication&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;Here is an example of a function that will appear in &lt;u&gt;all environments&lt;/u&gt; and assemblies. &lt;/p&gt;  &lt;p&gt;//***********************************   &lt;br /&gt;// Test code; remove when running on live.    &lt;br /&gt;//***********************************    &lt;br /&gt;&amp;#160; if (X==Y || Z==A) &lt;/p&gt;  &lt;p&gt;{&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int AnotherX = Convert.ToInt32(X)|    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.DebugFormat(&amp;quot;AnoterX has been set to {0}&amp;quot;, X);    &lt;br /&gt;&amp;#160; } &lt;/p&gt;  &lt;p&gt;Pleacing this within a Conditional Pre-Compilation Symbols would look like this: &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;#if(DEBUG)&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160; //***********************************   &lt;br /&gt;&amp;#160;&amp;#160; // Test code; remove when running on live.    &lt;br /&gt;&amp;#160;&amp;#160; //***********************************    &lt;br /&gt;&amp;#160;&amp;#160; if (X==Y || Z==A    &lt;br /&gt;&amp;#160;&amp;#160; {&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int AnotherX = Convert.ToInt32(X)|   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.DebugFormat(&amp;quot;AnoterX has been set to {0}&amp;quot;, X);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;#endif&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;This means that the code still works fine on you're local PC and Miranda, but now that we're using CC.NET to do a &amp;quot;Release&amp;quot; build, this code will not be included in the assembly. &lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Doing something more funky&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;You're not limited to just removing code, you can also directly change the code as shown below: &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;#if(DEBUG)&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.DebugFormat(&amp;quot;This is Debug Code&amp;quot;); &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;#else&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.DebugFormat(&amp;quot;This is Release Code&amp;quot;); &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;#endif&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;You are also not limited to only using the pre-configured &amp;quot;DEBUG&amp;quot; or &amp;quot;RELEASE&amp;quot; variables, you can also set your own.&amp;#160; To do this, open the property page for your project and select the Build tab.&amp;#160; Here you can see a field called &amp;quot;Conditional compilation symbols&amp;quot;.&amp;#160; Here you can enter a value like &amp;quot;Design&amp;quot;, but you should also note the Configuration currently selected as this is important.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-3MDKk7eI/AAAAAAAAAik/C2dkjataQuA/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-3Mm093LI/AAAAAAAAAio/0Jlyv68Pfdo/image_thumb.png?imgmax=800" width="244" height="125" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now in your code you can do this…. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160; #if(Design)&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _log.DebugFormat(&amp;quot;This is only run when Design is entered in the properties&amp;quot;); &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160; #endif&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;    &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p&gt;You can of course add as many build configurations as you wish, e.g. “Debug”, “Test”, “Stage”, “Live” etc. and CC.NET will happy ensure that each is built in turn correctly.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-8864066066843937956?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/8864066066843937956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/8864066066843937956'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/12/conditional-pre-complication-is-good.html' title='Conditional Pre-Complication is good for what ails you.'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh3.ggpht.com/_r_B45UywYok/S6-3Mm093LI/AAAAAAAAAio/0Jlyv68Pfdo/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-569288787765375526</id><published>2009-11-25T12:06:00.000-08:00</published><updated>2010-03-28T13:07:03.329-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Generics your easy road to the simple life</title><content type='html'>&lt;p&gt;There have been some comments recently asking what was the best way to use Generics in C#, so here’s a short blog which sheds some light.&amp;#160; Generics were probably the most powerful feature to go into .Net and they allowed developers to define structures, without committing to actual data types.&amp;#160; That may sound very complicated but its really not that hard to wrap your head around. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Simple Generic Lists&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;One of the simplest examples is taken directly from an existing Framework.&amp;#160; Within this we have lots of Collections classes for example CompanyCollection, ContactCollection, etc. and these are explicitly created with lots of code for getting a group, array of Company or Contact items from the CompanySearch class.&amp;#160; &lt;/p&gt;  &lt;p&gt;It's usually seen in this type of context: &lt;/p&gt;  &lt;p&gt;// Get a collection of companies &lt;/p&gt;  &lt;p&gt;CompanyCollection compCollection = CompanySearch.Browes(); &lt;/p&gt;  &lt;p&gt;string companyName = compCollection[0].CompName;&amp;#160; // display the first company name &lt;/p&gt;  &lt;p&gt;Generics give you the same thing out of the box using the List&amp;lt;&amp;gt; function. &lt;/p&gt;  &lt;p&gt;// Get a collection of companies using Generics &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;List&amp;lt;Company&amp;gt;&lt;/strong&gt; compCollection = CompanySearch.Browes(); &lt;/p&gt;  &lt;p&gt;string companyName = compCollection[0].CompName; &lt;/p&gt;  &lt;p&gt;So what's the advantage?&amp;#160; Well for one we don't need the CompanyCollection.cs class file which will save a developer having to write it (cut/paste or use replicator and perhaps introduce bugs).&amp;#160; Secondly it's been developed using core functions so it's faster than anything you could write yourself.&amp;#160; Also it's guaranteed to give us a stable upgrade path as .Net progresses. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Syntax&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;Taking this example a little further, I hear “What’s all this &amp;lt;&amp;gt; crap in the code?”.&amp;#160; Well simply, this is the class you are passing into a “generic” (i.e. self defined) method.&amp;#160; An easy way to describe this is to think of it as a cut/paste job for the class.&amp;#160; Below is an extract of the CompanyCollection class with a Browse method. &lt;/p&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections; &lt;/p&gt;  &lt;p&gt;namespace BusinessObjects.Companies   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class CompanyCollection : CollectionBase    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public CompanyColelction Browse()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CompanyCollection results = new CompanyCollection();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; … some code to find a bunch of records and put them in results …    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return results;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;If you wanted the same thing for Contacts you would probably cut/paste the code into a new file and replace every occurrence of “&amp;quot;CompanyCollection” with “ContactCollection”.&amp;#160; With Generics you would say something like this. &lt;/p&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections; &lt;/p&gt;  &lt;p&gt;namespace BusinessObjects.Companies   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class GenericList&amp;lt;T&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public GenericList&amp;lt;T&amp;gt; Browse()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; GenericList&amp;lt;T&amp;gt; results = new GenericList&amp;lt;T&amp;gt;();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; … some code to find a bunch of records and put them in results …    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return results;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Here at &lt;u&gt;compile time&lt;/u&gt; the .Net Framework will replace the “T” above with the object value you are passing to the method.&lt;/p&gt;  &lt;p&gt;GenericList&amp;lt;&lt;strong&gt;Company&lt;/strong&gt;&amp;gt; myCompanyCollection = new GenericList&amp;lt;&lt;strong&gt;Company&lt;/strong&gt;&amp;gt;();&amp;#160; // replace “T”     &lt;br /&gt;myCompanyCollection.Browse();&lt;/p&gt;  &lt;p&gt;&lt;em&gt;and&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;GenericList&amp;lt;Contact&amp;gt; myContactCollection = new GenericList&amp;lt;Contact&amp;gt;(); // replace “T”   &lt;br /&gt;myContactCollection.Browse();&lt;/p&gt;  &lt;p&gt;Hence in the compiled DLL, you do actually get two classes “generic classes” but you only have to write (or edit, debug, etc.) one!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-569288787765375526?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/569288787765375526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/569288787765375526'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/11/generics-your-easy-road-to-simple-life.html' title='Generics your easy road to the simple life'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2526911231990167449</id><published>2009-11-19T12:04:00.000-08:00</published><updated>2010-03-28T13:04:43.727-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Some coding tips and advice</title><content type='html'>&lt;p&gt;I've been doing some refactoring code recently and want to share some tips and tricks that could help developers in future efforts.&amp;#160; These are just suggestions so feel free to use or ignore any of them, but keep in mind that they would make things a little easier for everyone in the long run. &lt;/p&gt;  &lt;h3&gt;Temp Files and Paths&lt;/h3&gt;  &lt;p&gt;I've seen in a few places that developers have been placing files into the C:\temp directory.&amp;#160; Nothing wrong with this; however did you know that .NET makes it a lot easier now? &lt;/p&gt;  &lt;p&gt;Before:&amp;#160;&amp;#160;&amp;#160; string fullFileName = @&amp;quot;c:\temp\&amp;quot; + someFileName;   &lt;br /&gt;The main problem here this is that it assumes that the &amp;quot;c:\temp\&amp;quot; directory exists and if you want to change it we have to recompile the source code. &lt;/p&gt;  &lt;p&gt;After:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string fullFileName = String.Format(&amp;quot;{0}{1}&amp;quot;, &lt;strong&gt;Path.GetTempPath(),&lt;/strong&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;Path.GetTempFileName());     &lt;br /&gt;&lt;/strong&gt;The &amp;quot;Path&amp;quot; class in .NET will gives you lots of extra options for dealing with folders and files.&amp;#160; The &amp;quot;GetTempPath&amp;quot; method will return the value set in the %Temp% environment variable which is default in Windows.&amp;#160; &amp;quot;GetTempFileName&amp;quot; will give you a random filename which can be very handy if you are creating temp files.&amp;#160; Another handy methods are &amp;quot;GetFileNameWithoutExtension&amp;quot; which means you can add any extension you want to a file. &lt;/p&gt;  &lt;h3&gt;Getting rid of old code&lt;/h3&gt;  &lt;p&gt;You all know how much I *hate* to leave old code hanging around, but leaving an entire classes really gets me going!&amp;#160; The current Framework is chock full of classes that are old, duplicated or simply in need of a serious rewrite, but we can't delete them as there is the ever present &amp;quot;Possibility&amp;quot; of breaking the old ASP code.&amp;#160; To address this we can use the &amp;quot;Obsolete&amp;quot; attribute to show a class should no longer be used. &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; [&lt;strong&gt;Obsolete&lt;/strong&gt;(&amp;quot;This class is a deprecated! use Company from DataAccessObjects Namespace.&amp;quot;)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class Company    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&amp;#160;&amp;#160;&amp;#160;&amp;#160; ......&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;We can also say something like this&amp;#160; [Obsolete(&amp;quot;This class is a deprecated and will throw a compile error!&amp;quot;, &lt;strong&gt;true&lt;/strong&gt;)].&amp;#160; This is Visual Studio will generate a compile error, but it's probably not something you'd want to do unless you really wanted to spend a long time testing.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Never..Never.. Never.. Swallow Errors!&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;I've seen this type of code all over every project and it's really bad practice. &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; try { someCode;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; someMoreCode; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;catch (Exception e) { }     &lt;br /&gt;&lt;/strong&gt;AAGHHH!!! having a catch with nothing in it is like driving drunk with your eyes closed and having no insurance, it's just saying &amp;quot;If I crash, just keep going and leave all that damage for someone else&amp;quot;. &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; try { someCode;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; someMoreCode; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;catch (Exception e) { throw new e;}&lt;/strong&gt;    &lt;br /&gt;This is a little (but not much) better than the last example; least this this we acknowledge that a problem took place.&amp;#160; The problem with this approach is that as we're throwing a &amp;quot;new e&amp;quot; so we actually loose the strack trace and if the error is deep in the bowls of the code you'll have a hard job finding the cause. &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; try { someCode;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; someMoreCode; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;catch (Exception e) { throw;}&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This will give you both the error and the stack trace, but really at this point its probably easier to just say:&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; someCode;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; someMoreCode; &lt;/p&gt;  &lt;p&gt;So what's the moral of our story?&amp;#160; NEVER have a try-catch block unless you actually need to do something with it, log the error, throw a different error, it’s up to you but please do something in the catch block. &lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Creating Projects in the right folder&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;A very minor thing on the list is to keep an eye on the directory when you're adding a new project to an existing solution.&amp;#160; By default if I was to add a new project to a solution it will go under the root folder.&amp;#160; There however a text box on the New Project dialogue which gives you the option to add a subdirectory name. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2526911231990167449?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2526911231990167449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2526911231990167449'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/11/some-coding-tips-and-advice.html' title='Some coding tips and advice'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2685794837078614512</id><published>2009-11-13T11:59:00.000-08:00</published><updated>2010-03-28T12:59:55.223-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>PSTools .. it’s great to find a good tool for once!</title><content type='html'>&lt;p&gt;I was looking for a way to run scripts on a remote server and found this great set of tools that are freely available from Microsoft.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx" target="_blank"&gt;PSTools&lt;/a&gt;; this is basically a set of tools that let you manage a remote server as if it was a local one.&amp;#160; this contains a number of different commands which are all listed on the website.&amp;#160; I’m going to integrate the PSExec command into the project Build Scripts.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2685794837078614512?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2685794837078614512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2685794837078614512'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/11/pstools-its-great-to-find-good-tool-for.html' title='PSTools .. it’s great to find a good tool for once!'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-5062043222028423593</id><published>2009-11-09T11:58:00.000-08:00</published><updated>2010-03-28T12:59:07.546-07:00</updated><title type='text'>Unit Testing types for developers</title><content type='html'>&lt;p&gt;Well you all know I'm a big fan of Unit Testing but did you know all the different types of tests you can run?&amp;#160; In this Blog I'll go over some of the examples: &lt;/p&gt;  &lt;h3&gt;A simple class to test&lt;/h3&gt;  &lt;p&gt;First we need a simple class to test so I'll use a very, very simple addition and division example called SimpleClass.&amp;#160; It contains two methods Add and Division both of which take two integers and return results.&amp;#160; Here is the basic code.... &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public class SimpleClass   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Add two values    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;first&amp;quot;&amp;gt;first value to add&amp;lt;/param&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;second&amp;quot;&amp;gt;second value to add&amp;lt;/param&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;sum of both values&amp;lt;/returns&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public int Add(int first, int second)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return first + second;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Divide two values    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;first&amp;quot;&amp;gt;first value to divide&amp;lt;/param&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;second&amp;quot;&amp;gt;second value to divide&amp;lt;/param&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;division of both values&amp;lt;/returns&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public decimal Divide(int first, int second)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return first / second;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;h3&gt;Lets get down to the testing. &lt;/h3&gt;  &lt;p&gt;First off all you need a class decorated with the attribute [TestFixture] this will tell NUnit GUI to run the test from the external program.&amp;#160; Here you can see a basic test thats you've probably see a few times before. &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; [TestFixture]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class TestingExamples    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test(Description=&amp;quot;Basic Test&amp;quot;)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void SimpleClass_Test_A_Simple_Method()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleClass simpleClass = new SimpleClass();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int result = simpleClass.Add(10, 20);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(result == 30, &amp;quot;Result was not correct!&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;It's saying pass the values 10 and 20 into the Add method and expect to get the result 30.&amp;#160; Simple really, and probably the type of test you'l want to write over and over again.&amp;#160; Howere there are other options available. &lt;/p&gt;  &lt;h4&gt;Repeat Test &lt;/h4&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test(Description = &amp;quot;Repeat Test&amp;quot;), Repeat(30)]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void SimpleClass_Repeat_Test()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleClass simpleClass = new SimpleClass();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int result = simpleClass.Add(10, 20);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(result == 30, &amp;quot;Result was not correct!&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;By adding the Repeat(30) attribute to the test as shown this will run the test 30 times.&amp;#160; In this example it's not really a very useful test but if for example you want to test load on a server or perhaps populate a number of rows in a database it can be very useful. &lt;/p&gt;  &lt;h4&gt;Multipule Value Test &lt;/h4&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test(Description=&amp;quot;Multivalue Test&amp;quot;)]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [TestCase(10,20,30)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [TestCase(1,2,3)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [TestCase(7,6,13)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void SimpleClass_TestCase_With_Many_Inputs(int    &lt;br /&gt;firstInput, int secondInput, int expectedResult)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleClass simpleClass = new SimpleClass();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int result = simpleClass.Add(firstInput, secondInput);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(result == expectedResult, &amp;quot;Result was not correct!&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;Here I'm calling the test 3 times but passing 3 different values and testing against 3 different results.&amp;#160; By using the [TestCase] attribute you can just add more and more values to the same test. &lt;/p&gt;  &lt;h4&gt;Expected Exception Test &lt;/h4&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test(Description = &amp;quot;Expected Exception Test&amp;quot;)]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [ExpectedException(typeof(DivideByZeroException),    &lt;br /&gt;ExpectedMessage = &amp;quot;divide&amp;quot;, MatchType = MessageMatch.Contains)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void SimpleClass_TestCase_Divide_By_Zero()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleClass simpleClass = new SimpleClass();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; decimal result = simpleClass.Divide(0, 0);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;Here is a divide test that throws a divide by Zero error.&amp;#160; By using the ExpectedException attribute we catch the error thrown by the .Net function and then checks it's the correct one, in this case System.DivideByZeroException.&amp;#160; It also checks the message text for the text &amp;quot;divide&amp;quot; and uses the MessageMatch.Contains attribute to indicate the text can exist anywhere in the error message. &lt;/p&gt;  &lt;h4&gt;Explicit &lt;/h4&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test(Description = &amp;quot;Only Run when Explicitly chosen&amp;quot;), Explicit]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void SimpleClass_Explicit_Test_Of_Method()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleClass simpleClass = new SimpleClass();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int result = simpleClass.Add(10, 20);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(result == 30, &amp;quot;Result was not correct!&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;This is an interesting one for us in that it will only run when you &amp;quot;explicitly&amp;quot; select it to run using TestRunner or the Nunit GUI, if not it will be ignored during test runs.&amp;#160; You'd use this function if you wanted to have a UI test or specific test that won't run on the Build server. &lt;/p&gt;  &lt;h4&gt;MaxTime and TimeOut &lt;/h4&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test(Description = &amp;quot;Maxtime Test&amp;quot;), MaxTime(20)]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void&amp;#160; SimpleClass_Max_Time_In_Mili_Seconds()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleClass simpleClass = new SimpleClass();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int result = simpleClass.Add(10, 20);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(result == 30, &amp;quot;Result was not correct!&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test(Description = &amp;quot;Timeout Test&amp;quot;), Timeout(20)]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void SimpleClass_Ensure_Long_Running_Process_Does_Not_Time_Out()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleClass simpleClass = new SimpleClass();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int result = simpleClass.Add(10, 20);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(result == 30, &amp;quot;Result was not correct!&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;Timed tests are great for performance tests, here we specify that both tests need to run within 20 miliseconds.&amp;#160; What's the difference between them?&amp;#160; Well not a lot really so it's probably best to stick to Timeout and ignore MaxTime. &lt;/p&gt;  &lt;h4&gt;Platform &lt;/h4&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test(Description = &amp;quot;.Net exclude test&amp;quot;), Platform(Exclude = &amp;quot;NET-2.0&amp;quot;)]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void SimpleClass_Exclude_DotNet_Tests()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Other options relevant to us    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // WinXP, Win2003Server, Vista, Net-1.1, Mono    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleClass simpleClass = new SimpleClass();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int result = simpleClass.Add(10, 20);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(result == 30, &amp;quot;Result was not correct!&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;Probably not something we'd use very often but it may be useful in the future.&amp;#160; Here we specify that we this test should not be run under .Net 2.&amp;#160; Again the test is not important here what is important is that we can say things like only run a test on a Windows 2003 Server or only run the test on XP. &lt;/p&gt;  &lt;h4&gt;Random Values &lt;/h4&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test(Description = &amp;quot;Random value generation test&amp;quot;)]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void SimpleClass_Random_Values(    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Values(10, 20, 30)] int firstValue,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Random(1, 50, 5)] int secondValue)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // run 15 times.. 3 values by 5 random numbers    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleClass simpleClass = new SimpleClass();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int result = simpleClass.Add(firstValue, secondValue);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int testResult = firstValue + secondValue;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.IsTrue(result == testResult, &amp;quot;Result was not correct!&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;Finally sometimes you just can't be assed coming up with test data so in this case we use the [Random] attribute.&amp;#160; By saying [Random(1,50,5) int ]&amp;#160; I'm saying choose a number between 1 and 50 and run that test 5 times.&amp;#160; I've also added 3 additional [Values] 10,20 and 30 this means the test will run 15 times, i.e. 3 by 5&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-5062043222028423593?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/5062043222028423593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/5062043222028423593'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/11/unit-testing-types-for-developers.html' title='Unit Testing types for developers'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-5601538784676438678</id><published>2009-10-26T08:40:00.001-07:00</published><updated>2009-10-26T08:40:40.070-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='MonoTouch'/><title type='text'>Adding an Application Icon using MonoTouch</title><content type='html'>&lt;p&gt;Minor thing this time, I just wanted to add an icon to my application and wanted to see how that could be done with MonoTouch.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;First off you need a PNG files, on a Mac its easy to get a PNG by just using the &amp;lt;Shift&amp;gt;&amp;lt;Command&amp;gt;4 command. I happened to we watch Dr Who at the time so I dragged it across the area I wanted and bingo I get the file on my Desktop.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Now we create a folder called Resources in the project solution by right clicking the project and selecting Add / New Folder and enter the name "Resources". Next you drag the PNG file from the desktop into the folder and select "Copy" from the dialogue which will place the file into the project.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;OK, now we're at the stage of linking it up. Right click the project and select "Options". In the Project Options dialogue go down to the "Build" section and select the "iPhone Application". Here you'll see the "Application Icon" option where you can select the icon from the list.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-5601538784676438678?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/5601538784676438678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/5601538784676438678'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/10/adding-application-icon-using-monotouch.html' title='Adding an Application Icon using MonoTouch'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-1931068738930142002</id><published>2009-10-26T07:59:00.001-07:00</published><updated>2009-10-26T08:07:12.099-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='MonoTouch'/><category scheme='http://www.blogger.com/atom/ns#' term='Mono'/><title type='text'>Adding Gestures to OpenGL application</title><content type='html'>&lt;p&gt;In my &lt;a href="http://devrichardagreene.blogspot.com/2009/10/ive-been-trying-out-some-opengl-code-on.html"&gt;last post&lt;/a&gt; I created a spinning 3DCube using MonoTouch which was a big step for me into the area of graphics. This time I want to try to control the objects rotation using gestures. Simply put, I want the default behavior to be a spinning cube, but if I press the screen the spinning should stop and I should be able to move the view manually using my finger.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Starting and stopping the animation&lt;/b&gt;&lt;/p&gt;&lt;p&gt;First need to make the View aware of the Touch events by adding the Touch Began and TouchEnded events. Edit the Cube3DView.cs class and add the event delegates.&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;[MonoTouch.Foundation.Export(&amp;amp;quot;touchesBegan:withEvent:&amp;amp;quot;)]&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;public override void TouchesBegan (MonoTouch.Foundation.NSSet touches, UIEvent evt)&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;{&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;Console.WriteLine(&amp;amp;quot;Click began&amp;amp;quot;);&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;StopAnimation();&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;}&lt;/p&gt;&lt;p style="font: 12.0px Helvetica; min-height: 14.0px"&gt;[MonoTouch.Foundation.Export(&amp;amp;quot;touchesEnded:withEvent:&amp;amp;quot;)]&lt;br /&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;public override void TouchesEnded (MonoTouch.Foundation.NSSet touches, UIEvent evt)&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;{&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;Console.WriteLine(&amp;amp;quot;Click ended&amp;amp;quot;);&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;StartAnimation();&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;When doing this I noticed that there was a bug in the original code, setting the AnimationTimer to null did not stop the image rotation. So I had to invalidate the timer altogether, I’m not sure why at this stage but I’ll get back to it…&lt;br /&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;public void StopAnimation ()&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;{&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;   AnimationTimer = null;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;b&gt;   AnimationTimer.Invalidate ();&lt;/b&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;}&lt;/p&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; font-weight: bold; "&gt;Changing the orientation with a finger&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;At first this seemed like a simple step to just change the orientation angle of the rotation but as you’ll see it’s never quite as easy at that. First off I needed to find the point on the view where we start the touch and the point where the finger was taken off the screen. This can then be passed back into the rotation function.&lt;br /&gt;&lt;br /&gt;First I needed to add some extra code to store the X and Y coordinates. In the Code3DView.cs file we add two private variables.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;PointF &lt;em&gt;location;    // global for drag&lt;/em&gt;&lt;br /&gt;&lt;p&gt;&lt;em&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;PointF _startLocation; // global for tourch start&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Now we add come code to the TouchBegin and TouchEnd methods, we also add a new TouchMoved method. I’ve highlighted the code changes below.&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;em&gt;[MonoTouch.Foundation.Export(&amp;amp;quot;touchesBegan:withEvent:&amp;amp;quot;)]&lt;/em&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;em&gt;public override void TouchesBegan (MonoTouch.Foundation.NSSet touches, UIEvent evt)&lt;/em&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;em&gt;{&lt;/em&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;em&gt;&lt;b&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;var touch = (UITouch) evt.TouchesForView (this).AnyObject;&lt;/b&gt;&lt;/em&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;em&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;startLocation = touch.LocationInView(this);&lt;/em&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;StopAnimation ();&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;}&lt;/p&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; font-weight: bold; "&gt;[MonoTouch.Foundation.Export(&amp;amp;quot;touchesMoved:withEvent:&amp;amp;quot;)]&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; font-weight: bold; "&gt;public override void TouchesMoved (MonoTouch.Foundation.NSSet touches, UIEvent evt)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; font-weight: bold; "&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; "&gt;&lt;b&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;var touch = (UITouch) evt.TouchesForView (this).AnyObject;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;      &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; font-style: italic; font-weight: bold; "&gt;location = this.Frame.Location;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; font-weight: bold; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;location.X = touch.LocationInView(this).X;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; "&gt;&lt;b&gt;      &lt;/b&gt; &lt;b&gt;&lt;em&gt;location.Y = touch.LocationInView(this).Y;&lt;/em&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; font-weight: bold; "&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; "&gt;[MonoTouch.Foundation.Export(&amp;amp;quot;touchesEnded:withEvent:&amp;amp;quot;)]&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; "&gt;public override void TouchesEnded (MonoTouch.Foundation.NSSet touches, UIEvent evt)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; "&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; "&gt;&lt;b&gt;float angle = TrigonometryHelper.Angle(&lt;/b&gt;startLocation.X, _startLocation.Y, _location.X, _location.Y);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; font-weight: bold; "&gt;GL.Rotate (angle, 1.0f, 1.0f, 1.0f);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; "&gt;StartAnimation ();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; "&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You’ll see that I had to add a new helper class to the project called TrigonometryHelper this is a simple set of code to help me calculate some of the values. Google is your friend when it comes down to this type of thing. Create a new empty class called TrigonometryHelper.cs and past in the following code.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; "&gt;using System;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, serif; font-size: 12px; "&gt;namespace DCudeDemo&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="font-family:Helvetica, serif;font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;{&lt;br /&gt;public static class TrigonometryHelper&lt;br /&gt;{&lt;br /&gt;public static float Angle(double px1, double py1, double px2, double py2)&lt;br /&gt;{&lt;br /&gt;// Negate X and Y values&lt;br /&gt;double pxRes = px2 - px1;&lt;br /&gt;double pyRes = py2 - py1;&lt;br /&gt;double angle = 0.0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:Helvetica, serif;font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;// Calculate the angle&lt;br /&gt;if (pxRes == 0.0)&lt;br /&gt;{&lt;br /&gt;if (pxRes == 0.0)&lt;br /&gt;angle = 0.0;&lt;br /&gt;else if (pyRes &amp;gt; 0.0)&lt;br /&gt;angle = System.Math.PI / 2.0;&lt;br /&gt;else&lt;br /&gt;angle = System.Math.PI * 3.0 / 2.0;&lt;br /&gt;}&lt;br /&gt;else if (pyRes == 0.0)&lt;br /&gt;{&lt;br /&gt;if (pxRes &amp;gt; 0.0)&lt;br /&gt;angle = 0.0;&lt;br /&gt;else&lt;br /&gt;angle = System.Math.PI;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;if (pxRes &amp;lt; 0.0)&lt;br /&gt;angle = System.Math.Atan(pyRes / pxRes) + System.Math.PI;&lt;br /&gt;else if (pyRes &amp;lt; 0.0)&lt;br /&gt;angle = System.Math.Atan(pyRes / pxRes) + (2 * System.Math.PI);&lt;br /&gt;else&lt;br /&gt;angle = System.Math.Atan(pyRes / pxRes);&lt;br /&gt;}&lt;br /&gt;// Convert to degrees&lt;br /&gt;angle = angle * 180 / System.Math.PI;&lt;br /&gt;return float.Parse(angle.ToString());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;This is a class that I’m sure will begin to expand in functionality later.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Compiling and running the application now allows you to change the orientation of the cube with your finger.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&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/7889773289404691484-1931068738930142002?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1931068738930142002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1931068738930142002'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/10/adding-gestures-to-opengl-application.html' title='Adding Gestures to OpenGL application'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-9118176215422083429</id><published>2009-10-25T10:21:00.000-07:00</published><updated>2009-10-25T10:49:15.036-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='MonoTouch'/><category scheme='http://www.blogger.com/atom/ns#' term='Mono'/><title type='text'>3D Cube using MonoTouch on the iPhone</title><content type='html'>&lt;div style="text-align: left;"&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;I've been trying out some OpenGL code on the iPhone which is way out of my comfort zone. It's the first time i've posted anything using MonoTouch also, but with any luck if I can continue to work in this area it may lead to some new innovations. My first project in this area would be to create a 3D cube and rotate it. Sounds simple, but finding posting and same code using MonoTouch turn out to be impossible. "How hard can it be?" I said to myself, well .. lets see....&lt;/div&gt;&lt;p&gt;&lt;b&gt;Creating the project&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://monotouch.net/"&gt;MonoTouch&lt;/a&gt; and &lt;a href="http://monodevelop.com/" title="MonoDevelop"&gt;MonoDevelop&lt;/a&gt; makes this very easy indeed, just start the IDE and select File/New/Solution, select iPhone/iPhone MonoTouch Project and give it the name 3DCubeDemo.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 303px;" src="http://4.bp.blogspot.com/_r_B45UywYok/SuSJaJzR04I/AAAAAAAAAP8/TEAsRpTqGpw/s320/Picture+3.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5396589335897297794" /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Click Forward and then OK.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This will give you a standard project structure with a Main.cs file which is the same as the ApplicationDelegate and a MainWindow.xib file which is the InterfaceBuilder file for defining the interface.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_r_B45UywYok/SuSJ8CBxwPI/AAAAAAAAAQE/PHQ4VTO6Rr4/s1600-h/Picture+4.png"&gt;&lt;img src="http://4.bp.blogspot.com/_r_B45UywYok/SuSJ8CBxwPI/AAAAAAAAAQE/PHQ4VTO6Rr4/s320/Picture+4.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5396589917926179058" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Adding our View&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;First step is to create a view onto which we can apply our 3D Cube. Double Click the MainWindow.xib file which should start Interface Builder.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Drag a new view Control from the "Windows, Views &amp;amp; Bars" section in the Library onto the Window.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_r_B45UywYok/SuSKCCu7zsI/AAAAAAAAAQM/mA7EUtC8i3A/s1600-h/Picture+6.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 198px;" src="http://2.bp.blogspot.com/_r_B45UywYok/SuSKCCu7zsI/AAAAAAAAAQM/mA7EUtC8i3A/s320/Picture+6.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5396590021194796738" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Change the View class field to "Cube3DView" and the Interface Name to Cube3DView.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Select the App Delegate and Create a new outlet called cude3DView. Then connect this to the view by dragging the link to the View called Cube3DView.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_r_B45UywYok/SuSKu8g-UJI/AAAAAAAAAQU/oztFCMgF4pg/s1600-h/Picture+7.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 198px;" src="http://4.bp.blogspot.com/_r_B45UywYok/SuSKu8g-UJI/AAAAAAAAAQU/oztFCMgF4pg/s320/Picture+7.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5396590792619741330" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Save the file and close InterfaceBuilder.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Doing the code thing...&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;When you save the file in interface Builder you'll see that it automatically updates your MainWindow.xib.designer.cs file with a partial class called Cube3DView and add a property to the AppDelegate called cube3Dview. This is all fine if we just wanted to use the out of the box UIView methods but in this case we need a bit more access. best thing to do is modify the property so it returns a full Cude3DView class as opposed to the default UIView.&lt;p&gt; [MonoTouch.Foundation.Connect("cube3DView")]&lt;br /&gt;private MonoTouch.UIKit.UIView cube3DView {&lt;br /&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;get {&lt;/p&gt;&lt;p&gt;return ((MonoTouch.UIKit.UIView)(this.GetNativeField("cube3DView")));&lt;br /&gt;}&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;set {&lt;br /&gt;this.SetNativeField("cube3DView", value);&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;}&lt;p&gt;&lt;/p&gt;&lt;p&gt;becomes&lt;/p&gt;&lt;p&gt;[MonoTouch.Foundation.Connect("cube3DView")]&lt;br /&gt;private &lt;b&gt;Cube3DView&lt;/b&gt; cube3DView {&lt;br /&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;get {&lt;/p&gt;&lt;p&gt;return ((&lt;strong&gt;Cube3DView&lt;/strong&gt;)(this.GetNativeField("cube3DView")));&lt;br /&gt;}&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;set {&lt;br /&gt;this.SetNativeField("cube3DView", value);&lt;br /&gt;}&lt;/blockquote&gt;&lt;br /&gt;}&lt;p&gt;&lt;/p&gt;&lt;br /&gt;and&lt;br /&gt;// Base type probably should be MonoTouch.UIKit.UIView or subclass&lt;br /&gt;&lt;p&gt;[MonoTouch.Foundation.Register("Cube3DView")]&lt;br /&gt;public partial class Cube3DView {&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;becomes&lt;br /&gt;&lt;/p&gt;&lt;p&gt;// Base type probably should be MonoTouch.UIKit.UIView or subclass&lt;br /&gt;[MonoTouch.Foundation.Register("Cube3DView")]&lt;br /&gt;public partial class Cube3DView &lt;b&gt;: MonoTouch.UIKit.UIView&lt;/b&gt;  {&lt;br /&gt;}&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: This is a problem for the moment as once you edit the view again in InterfaceBuilder it will overwrite your changes. I'll keep looking out for better solutions using partial classes.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Creating the Model and link to OpenGL.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Create a new class file called Cube3DViewand place the following code into the file. I've bolded some of the more interesting areas;&lt;/p&gt;&lt;blockquote&gt;using System;&lt;br /&gt;using System.Drawing;&lt;br /&gt;using MonoTouch.CoreAnimation;&lt;br /&gt;using MonoTouch.CoreGraphics;&lt;br /&gt;using MonoTouch.Foundation;&lt;br /&gt;using MonoTouch.OpenGLES;&lt;br /&gt;using MonoTouch.UIKit;&lt;br /&gt;using MonoTouch.ObjCRuntime;&lt;br /&gt;using OpenTK.Graphics;&lt;br /&gt;using OpenTK.Graphics.ES11;&lt;br /&gt;using OpenTK.Platform;&lt;br /&gt;using OpenTK.Platform.iPhoneOS;&lt;br /&gt;&lt;br /&gt;namespace DCudeDemo&lt;br /&gt;{&lt;br /&gt;public partial class Cube3DView : UIView {&lt;br /&gt;int BackingWidth;&lt;br /&gt;int BackingHeight;&lt;br /&gt;iPhoneOSGraphicsContext Context;&lt;br /&gt;uint ViewRenderBuffer, ViewFrameBuffer;&lt;br /&gt;uint DepthRenderBuffer;&lt;br /&gt;NSTimer AnimationTimer;&lt;br /&gt;internal double AnimationInterval;&lt;br /&gt;&lt;br /&gt;const bool UseDepthBuffer = false;&lt;br /&gt;&lt;br /&gt;[Export ("layerClass")]&lt;br /&gt;public static Class LayerClass ()&lt;br /&gt;{&lt;br /&gt;return new Class (typeof (CAEAGLLayer));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;[Export ("initWithCoder:")]&lt;br /&gt;public Cube3DView (NSCoder coder) : base (coder)&lt;br /&gt;{&lt;br /&gt;CAEAGLLayer eaglLayer = (CAEAGLLayer) Layer;&lt;br /&gt;eaglLayer.Opaque = true;&lt;br /&gt;eaglLayer.DrawableProperties = NSDictionary.FromObjectsAndKeys (&lt;br /&gt;new NSObject []{NSNumber.FromBoolean(false),          EAGLColorFormat.RGBA8},&lt;br /&gt;new NSObject []{EAGLDrawableProperty.RetainedBacking, EAGLDrawableProperty.ColorFormat}&lt;br /&gt;);&lt;br /&gt;Context = (iPhoneOSGraphicsContext) ((IGraphicsContextInternal) GraphicsContext.CurrentContext).Implementation;&lt;br /&gt;&lt;br /&gt;Context.MakeCurrent(null);&lt;br /&gt;AnimationInterval = 1.0 / 60.0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void DrawView ()&lt;br /&gt;{&lt;br /&gt;&lt;b&gt;   float[] cube = {&lt;br /&gt; -0.5f,  0.5f,  0.5f, // vertex[0]&lt;br /&gt;  0.5f,  0.5f,  0.5f, // vertex[1]&lt;br /&gt;  0.5f, -0.5f,  0.5f, // vertex[2]&lt;br /&gt; -0.5f, -0.5f,  0.5f, // vertex[3]&lt;br /&gt; -0.5f,  0.5f, -0.5f, // vertex[4]&lt;br /&gt;  0.5f,  0.5f, -0.5f, // vertex[5]&lt;br /&gt;  0.5f, -0.5f, -0.5f, // vertex[6]&lt;br /&gt; -0.5f, -0.5f, -0.5f, // vertex[7]&lt;br /&gt;};&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;byte[] triangles = {&lt;br /&gt;1, 0, 2, // front&lt;br /&gt;  3, 2, 0,&lt;br /&gt;  6, 4, 5, // back&lt;br /&gt;  4, 6, 7,&lt;br /&gt;  4, 7, 0, // left&lt;br /&gt;  7, 3, 0,&lt;br /&gt;  1, 2, 5, //right&lt;br /&gt;  2, 6, 5,&lt;br /&gt;  0, 1, 5, // top&lt;br /&gt;  0, 5, 4,&lt;br /&gt;  2, 3, 6, // bottom&lt;br /&gt;  3, 7, 6,&lt;br /&gt;};&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;  float[] cubeColors = {&lt;br /&gt; 1.0f, 0.0f, 0.0f, 1.0f,&lt;br /&gt; 0.0f, 1.0f, 0.0f, 1.0f,&lt;br /&gt; 0.0f, 0.0f, 1.0f, 1.0f,&lt;br /&gt; 0.0f, 1.0f, 1.0f, 1.0f,&lt;br /&gt; 1.0f, 0.0f, 0.0f, 1.0f,&lt;br /&gt; 0.0f, 1.0f, 0.0f, 1.0f,&lt;br /&gt; 0.0f, 0.0f, 1.0f, 1.0f,&lt;br /&gt; 0.0f, 1.0f, 1.0f, 1.0f,&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;Context.MakeCurrent(null);&lt;br /&gt;GL.Oes.BindFramebuffer (All.FramebufferOes, ViewFrameBuffer);&lt;br /&gt;GL.Viewport (0, 0, BackingWidth, BackingHeight);&lt;br /&gt;&lt;br /&gt;GL.Enable(All.CullFace);&lt;br /&gt;GL.MatrixMode (All.Projection);&lt;br /&gt;GL.LoadIdentity ();&lt;br /&gt;GL.Ortho (-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);&lt;br /&gt;GL.MatrixMode (All.Modelview);&lt;br /&gt;&lt;b&gt;   GL.Rotate (3.0f, 0.0f, 2.0f, 1.0f);&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;GL.ClearColor (0.5f, 0.5f, 0.5f, 1.0f);&lt;br /&gt;GL.Clear ((uint) All.ColorBufferBit);&lt;br /&gt;&lt;br /&gt;&lt;b&gt;   GL.VertexPointer(3, All.Float, 0, cube);&lt;br /&gt;&lt;/b&gt;   GL.EnableClientState (All.VertexArray);&lt;br /&gt;GL.ColorPointer (4, All.Float, 0, cubeColors);&lt;br /&gt;GL.EnableClientState (All.ColorArray);&lt;br /&gt;&lt;b&gt;   GL.DrawElements(All.Triangles, 36, All.UnsignedByte, triangles);&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;GL.Oes.BindRenderbuffer (All.RenderbufferOes, ViewRenderBuffer);&lt;br /&gt;Context.EAGLContext.PresentRenderBuffer ((uint) All.RenderbufferOes);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public override void LayoutSubviews ()&lt;br /&gt;{&lt;br /&gt;Context.MakeCurrent(null);&lt;br /&gt;DestroyFrameBuffer ();&lt;br /&gt;CreateFrameBuffer ();&lt;br /&gt;DrawView ();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;bool CreateFrameBuffer ()&lt;br /&gt;{&lt;br /&gt;GL.Oes.GenFramebuffers (1, ref ViewFrameBuffer);&lt;br /&gt;GL.Oes.GenRenderbuffers (1, ref ViewRenderBuffer);&lt;br /&gt;&lt;br /&gt;GL.Oes.BindFramebuffer (All.FramebufferOes, ViewFrameBuffer);&lt;br /&gt;GL.Oes.BindRenderbuffer (All.RenderbufferOes, ViewRenderBuffer);&lt;br /&gt;Context.EAGLContext.RenderBufferStorage ((uint) All.RenderbufferOes, (CAEAGLLayer) Layer);&lt;br /&gt;GL.Oes.FramebufferRenderbuffer (All.FramebufferOes,&lt;br /&gt;All.ColorAttachment0Oes,&lt;br /&gt;All.RenderbufferOes,&lt;br /&gt;ViewRenderBuffer);&lt;br /&gt;&lt;br /&gt;GL.Oes.GetRenderbufferParameter (All.RenderbufferOes, All.RenderbufferWidthOes, ref BackingWidth);&lt;br /&gt;GL.Oes.GetRenderbufferParameter (All.RenderbufferOes, All.RenderbufferHeightOes, ref BackingHeight);&lt;br /&gt;&lt;br /&gt;if (GL.Oes.CheckFramebufferStatus (All.FramebufferOes) != All.FramebufferCompleteOes) {&lt;br /&gt;Console.Error.WriteLine("failed to make complete framebuffer object {0}",&lt;br /&gt; GL.Oes.CheckFramebufferStatus (All.FramebufferOes));&lt;br /&gt;}&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void DestroyFrameBuffer ()&lt;br /&gt;{&lt;br /&gt;GL.Oes.DeleteFramebuffers (1, ref ViewFrameBuffer);&lt;br /&gt;ViewFrameBuffer = 0;&lt;br /&gt;GL.Oes.DeleteRenderbuffers (1, ref ViewRenderBuffer);&lt;br /&gt;ViewRenderBuffer = 0;&lt;br /&gt;&lt;br /&gt;if (DepthRenderBuffer != 0) {&lt;br /&gt;GL.Oes.DeleteRenderbuffers (1, ref DepthRenderBuffer);&lt;br /&gt;DepthRenderBuffer = 0;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void StartAnimation ()&lt;br /&gt;{&lt;br /&gt;AnimationTimer = NSTimer.CreateRepeatingScheduledTimer (TimeSpan.FromSeconds (AnimationInterval), () =&amp;gt; DrawView ());&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void StopAnimation ()&lt;br /&gt;{&lt;br /&gt;AnimationTimer = null;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void SetAnimationTimer (NSTimer timer)&lt;br /&gt;{&lt;br /&gt;AnimationTimer.Invalidate ();&lt;br /&gt;AnimationTimer = timer;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void SetAnimationInterval (double interval)&lt;br /&gt;{&lt;br /&gt;AnimationInterval = interval;&lt;br /&gt;if (AnimationTimer != null) {&lt;br /&gt;StopAnimation ();&lt;br /&gt;StartAnimation ();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/blockquote&gt;&lt;p style="font: 12.0px Helvetica"&gt;I can't really take all the credit for this script as it's mainly a modification of the 2D sample provided on the MonoTouch site. There were however a number of changes needed to work this into a 3D model. The "cube[]" array of floats contains all the data for the model, these are simple X, Y, Z coordinates positioned from 0,0,0 at the centre. The triangles byte array for geometry, where I get a bit fuzzy on the whole thing, check out the &lt;a href="http://tapium.com/wp-content/uploads/2009/06/iphone-dev-school-iphone-opengl-es-crash-course.pdf" title="iphone-opengl"&gt;iPhone OpenGL&lt;/a&gt; article which I used as a base for my example. The other functions should be self explanatory GL.Rotate, GL.VertexPointer and GL.DrawElements are where all the data comes together.&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;Once you compile you'll get the error "The type or namespace 'OpenTK' could not be found" error. OpenTK is simply the Mono implementation of the OpenGL infrastructure so all you need to do is add this as a project reference. &amp;lt;Ctrl&amp;gt; Click the References folder in your solution and select "Edit References...".&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_r_B45UywYok/SuSK7B5PcgI/AAAAAAAAAQc/LkbTdYZeAgs/s1600-h/Picture+8.png"&gt;&lt;br /&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 295px;" src="http://2.bp.blogspot.com/_r_B45UywYok/SuSK7B5PcgI/AAAAAAAAAQc/LkbTdYZeAgs/s320/Picture+8.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5396591000222134786" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="font: 12.0px Helvetica"&gt;Click the OpenTK reference and click OK.&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;span class="Apple-style-span"   style="font-family:Georgia, serif;font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="font-size:16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;Finally we need to initialize this new class correctly in the Main.cs file. Open the Main.cs file and add the following using commands at the top of the file.&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: 12px Helvetica;"&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: 12px Helvetica;"&gt;using OpenTK.Platform;&lt;/p&gt;&lt;br /&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: 12px Helvetica;"&gt;using MonoTouch.OpenGLES;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Helvetica, serif;font-size:12px;"&gt;Modify the Main entry point to the application so it tells the UIApplication that we will be making use of OpenGL.&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;span class="Apple-style-span"   style="font-family:Georgia, serif;font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="font-size:16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;static void Main (string[] args)&lt;br /&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;{&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;b&gt;using (var c = Utilities.CreateGraphicsContext(EAGLRenderingAPI.OpenGLES1)) {&lt;/b&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;UIApplication.Main (args);&lt;br /&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;b&gt;}&lt;/b&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="font: 12.0px Helvetica"&gt;}&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;span class="Apple-style-span"   style="font-family:Georgia, serif;font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="font-size:16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;Modify the AppDelegate "FinishedLoading" method so that it initializes the animation;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p style="font: 12.0px Helvetica"&gt;public override bool FinishedLaunching (UIApplication app, NSDictionary options)&lt;br /&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;{&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p style="font: 12.0px Helvetica"&gt;// If you have defined a view, add it here:&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;// window.AddSubview (navigationController.View);&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;window.MakeKeyAndVisible ();&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;b&gt;cube3DView.AnimationInterval = 1.0 / 60.0;&lt;/b&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;b&gt;cube3DView.StartAnimation();&lt;/b&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;return true;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;}&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;/p&gt;&lt;br /&gt;&lt;p style="font: 12.0px Helvetica"&gt;Compile and run the application and you should see the following appear in the simulator:&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;&lt;span class="Apple-style-span"   style="font-family:Georgia, serif;font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="font-size:16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_r_B45UywYok/SuSK_EvsnAI/AAAAAAAAAQk/bc_1cLAcxVg/s1600-h/Picture+9.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 165px; height: 320px;" src="http://3.bp.blogspot.com/_r_B45UywYok/SuSK_EvsnAI/AAAAAAAAAQk/bc_1cLAcxVg/s320/Picture+9.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5396591069706886146" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font: 12.0px Helvetica"&gt;How good is that!?!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-9118176215422083429?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/9118176215422083429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/9118176215422083429'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/10/ive-been-trying-out-some-opengl-code-on.html' title='3D Cube using MonoTouch on the iPhone'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://4.bp.blogspot.com/_r_B45UywYok/SuSJaJzR04I/AAAAAAAAAP8/TEAsRpTqGpw/s72-c/Picture+3.png' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2124035766358502089</id><published>2009-10-02T12:56:00.000-07:00</published><updated>2010-03-28T12:56:27.912-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Old Include files are a pain</title><content type='html'>&lt;p&gt;Noticed an issue with migrating old ASP application to our new CruiseControl deployment model today.&amp;#160; That is, using of ASP include files *.inc in your project causes Visual Studio to not deploy these to the “Published” sites as it does not understand the file extension.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-0ZjgSTmI/AAAAAAAAAiU/yHLpB_az-AU/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-0aL5bAXI/AAAAAAAAAiY/THQ83feJfN4/image_thumb.png?imgmax=800" width="211" height="244" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;In the example above you can see that the Build Action is “None”.&lt;/p&gt;  &lt;p&gt;To get around this you need to manually set the Build Action property to “Content” in Visual Studio.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-0aVVURCI/AAAAAAAAAic/Zcx3aas57AQ/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-0a5ntg2I/AAAAAAAAAig/YEu7rN3PLoM/image_thumb1.png?imgmax=800" width="244" height="115" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;From that point on the file will be automatically included with the deployment of the site.&amp;#160; This will not affect any of the new ASP.NET solutions, only the very old ASP solutions.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2124035766358502089?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2124035766358502089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2124035766358502089'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/10/old-include-files-are-pain.html' title='Old Include files are a pain'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh3.ggpht.com/_r_B45UywYok/S6-0aL5bAXI/AAAAAAAAAiY/THQ83feJfN4/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-7218294966759317254</id><published>2009-09-15T12:54:00.000-07:00</published><updated>2010-03-28T12:54:58.993-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Using Selenium Tests and MasterPages</title><content type='html'>&lt;p&gt;It was recently noted to me that running Selenium UnitTests can be a problem when the developer is using MasterPages and UserControls. This is due to the fact that when recording the test on one PC, the ControlID used my change depending on the server used.&lt;/p&gt;  &lt;p&gt;A normal Selenium Test will produce code such as this :&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; [TestFixture]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class WebTest    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&lt;em&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; … code sniped as not needed for demo …&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void MySeleniumTest()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; selenium.Open(&amp;quot;/somesite/default.aspx&amp;quot;);   &lt;br /&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; selenium.Click(&amp;quot;ctl02_ctl00_ButtonLaunch&amp;quot;);     &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; selenium.WaitForPageToLoad(&amp;quot;30000&amp;quot;);    &lt;br /&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; selenium.Click(&amp;quot;ctl02_ctl00_ButtonSubmit&amp;quot;);     &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;The ControlID to click is found using the code &amp;quot;ctl02_ctl00_ButtonLaunch&amp;quot;; however on another server it may be generated as&amp;#160; “ctl&lt;strong&gt;0&lt;/strong&gt;02_ctl00_ButtonLaunch” or “ctl02_ct&lt;strong&gt;0&lt;/strong&gt;100_ButtonLaunch”, which would cause the test to fail.&lt;/p&gt;  &lt;p&gt;To address this you add the following code to the test class or to a base selenium test class, if you have a number of tests running;&lt;/p&gt;  &lt;p&gt;//******************************************************************/   &lt;br /&gt;//    &lt;br /&gt;//&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Helper Methods    &lt;br /&gt;//    &lt;br /&gt;//******************************************************************/ &lt;/p&gt;  &lt;p&gt;/// &amp;lt;summary&amp;gt;   &lt;br /&gt;/// Simple function to pre-append masterpage text to a control     &lt;br /&gt;/// &amp;lt;/summary&amp;gt;    &lt;br /&gt;/// &amp;lt;param name=&amp;quot;control&amp;quot;&amp;gt;text name of the control&amp;lt;/param&amp;gt;    &lt;br /&gt;/// &amp;lt;returns&amp;gt;control name with additional text&amp;lt;/returns&amp;gt;    &lt;br /&gt;private string ControlName(string control)    &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return ControlName(control, 0);    &lt;br /&gt;} &lt;/p&gt; /// &amp;lt;summary&amp;gt;  &lt;br /&gt;/// Simple function to pre-append masterpage text to a control   &lt;br /&gt;/// &amp;lt;/summary&amp;gt;  &lt;br /&gt;/// &amp;lt;param name=&amp;quot;control&amp;quot;&amp;gt;text name of the control&amp;lt;/param&amp;gt;  &lt;br /&gt;/// &amp;lt;param name=&amp;quot;iteration&amp;quot;&amp;gt;number to look for&amp;lt;/param&amp;gt;  &lt;br /&gt;/// &amp;lt;returns&amp;gt;control name with additional text&amp;lt;/returns&amp;gt;   &lt;p&gt;private string ControlName(string control, int iteration)   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; int counter = 0;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; string pattern = String.Format(@&amp;quot;\bid=.[^ ]*{0}\b&amp;quot;, control);&amp;#160;&amp;#160; //@&amp;quot;id=.*?{0}&amp;quot;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; string reference = String.Empty; // the correct reference    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; MatchCollection matches = Regex.Matches(selenium.GetHtmlSource(), pattern, RegexOptions.IgnoreCase);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; foreach (Match match in matches)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // work out the control name from the ref:master:control format    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; control = match.Value.Replace(&amp;quot;id=&amp;quot;, &amp;quot;&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (counter &amp;gt;= iteration) break;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; counter++;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return control;    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;This simply uses the HTML to search for the correct ControlID using regular expressions. I’ve added an Overload in case you use the same UserControl on the same page a number of times so you can target a specific version.&amp;#160; If excluded it will simply return the first. &lt;/p&gt;  &lt;p&gt;Now all you need to do is edit your test code to the following: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Test]   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void MySeleniumTest()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; selenium.Open(&amp;quot;/somesite/default.aspx&amp;quot;);   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; selenium.Click(&lt;strong&gt;ControlName(&amp;quot;ButtonLaunch&amp;quot;));&lt;/strong&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; selenium.WaitForPageToLoad(&amp;quot;30000&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; selenium.Click(&lt;strong&gt;ControlName(&amp;quot;ButtonSubmit&amp;quot;));&lt;/strong&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-7218294966759317254?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/7218294966759317254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/7218294966759317254'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/09/using-selenium-tests-and-masterpages.html' title='Using Selenium Tests and MasterPages'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2247703681532489509</id><published>2009-09-11T12:53:00.000-07:00</published><updated>2010-03-28T12:53:32.539-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Using ASP.NET Ajax controls</title><content type='html'>&lt;p&gt;Here is a simple tutorial of the simplest of the Ajax functions called the “Partial Page Update”, this shows how to use the built in Visual Studio 2008 controls.&amp;#160; You will see from this that there is no need to write any of that old JavaScript plumbing and how simple it is to implement.&amp;#160; &lt;/p&gt;  &lt;h3&gt;Setting up your project&lt;/h3&gt;  &lt;p&gt;Start a new Visual Studio Project called AjaxDemo.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-zqeADvTI/AAAAAAAAAhs/4prbgKJqxMA/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-zqpAiDMI/AAAAAAAAAhw/XahkWiRKQD0/image_thumb.png?imgmax=800" width="244" height="179" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Add two text boxes to your default.aspx page called TextBox1 and TextBox2. then add a button called “Button1” with the text “Press Me”, the code is shown below:&lt;/p&gt;  &lt;p&gt;&amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;   &lt;br /&gt;&amp;lt;div&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:TextBox ID=&amp;quot;TextBox1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;p /&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:TextBox ID=&amp;quot;TextBox2&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;p /&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:Button ID=&amp;quot;Button1&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;quot;Press Me&amp;quot; /&amp;gt;    &lt;br /&gt;&amp;lt;/div&amp;gt;    &lt;br /&gt;&amp;lt;/form&amp;gt; &lt;/p&gt;  &lt;p&gt;Next on the code behind (default.aspx.cs) add the following code to the Page_Load function which populates the text boxes with the current time.&lt;/p&gt;  &lt;p&gt;protected void Page_Load(object sender, EventArgs e)   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; TextBox1.Text = DateTime.Now.ToLongTimeString();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; TextBox2.Text = DateTime.Now.ToLongTimeString();    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;Run the application and it should look like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-zrdk9g6I/AAAAAAAAAh0/JMBnxq4FyVQ/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-zr2Mq7dI/AAAAAAAAAh4/z8ihTTJp7AU/image_thumb1.png?imgmax=800" width="244" height="175" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Pressing the button will cause a refresh of the page and both fields to be updated.&lt;/p&gt;  &lt;h3&gt;Implementing the Partial Page Update Ajax commands&lt;/h3&gt;  &lt;p&gt;To allow for Ajax on your page you need to add a ScriptManager Control.&amp;#160; this should be placed on the page before any other controls are rendered.&amp;#160; I find putting in on the Master Page works best, that way you don’t have to worry about it later. &lt;/p&gt;  &lt;p&gt;1) Drag the ScriptManager from the tools in Visual Studio onto the design or code surface.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-zsaJvtqI/AAAAAAAAAh8/hbEALWea-Uk/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-zszcFn7I/AAAAAAAAAiA/cxOXJ9FSoeQ/image_thumb2.png?imgmax=800" width="244" height="151" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;2) Next you need to add an UpdatePanel around the controls you want to take part in the partial update.&amp;#160; In this case I’m going to wrap TextBox2 and Button1.&amp;#160; Again simply drag the item from the tool box to your design or code surface.&amp;#160; move your controls between the UpdatePanel tags and add a &amp;lt;ContentTemplate&amp;gt; tag around the controls.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-ztc0cZeI/AAAAAAAAAiE/GIEpI2YrwdE/s1600-h/image14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-zuGEEnuI/AAAAAAAAAiI/unbLS3ZB-mE/image_thumb4.png?imgmax=800" width="244" height="174" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The code should look something like this:&lt;/p&gt;  &lt;p&gt;&amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;   &lt;br /&gt;&amp;lt;asp:ScriptManager ID=&amp;quot;ScriptManager1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;    &lt;br /&gt;&amp;lt;/asp:ScriptManager&amp;gt;    &lt;br /&gt;&amp;lt;div&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:TextBox ID=&amp;quot;TextBox1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;p /&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:UpdatePanel ID=&amp;quot;UpdatePanel1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ContentTemplate&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:TextBox ID=&amp;quot;TextBox2&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;p /&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:Button ID=&amp;quot;Button1&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;quot;Press Me&amp;quot; /&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/ContentTemplate&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/asp:UpdatePanel&amp;gt;     &lt;br /&gt;&amp;lt;/div&amp;gt;    &lt;br /&gt;&amp;lt;/form&amp;gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Now press Play on your solution to see it in action.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-zut27TpI/AAAAAAAAAiM/3_q6jDHRpAA/s1600-h/image20.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-zuxA-qyI/AAAAAAAAAiQ/48XUNDFbGaY/image_thumb6.png?imgmax=800" width="197" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Pressing the button now will cause the second textbox to become updated but not the first as it is outside the update panel.&amp;#160; Also there will be no full Post Back event for the page refresh.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2247703681532489509?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2247703681532489509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2247703681532489509'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/09/using-aspnet-ajax-controls.html' title='Using ASP.NET Ajax controls'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/S6-zqpAiDMI/AAAAAAAAAhw/XahkWiRKQD0/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-4652428448141598853</id><published>2009-08-14T12:51:00.000-07:00</published><updated>2010-03-28T12:51:38.136-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>New version of Google Search Engine</title><content type='html'>&lt;p&gt;In case anyone missed this news, Google are releasing a new version of their search engine to the public &lt;a title="http://www2.sandbox.google.com/" href="http://www2.sandbox.google.com/"&gt;http://www2.sandbox.google.com/&lt;/a&gt;.&amp;#160; I did not see any real difference with the existing one but maybe you will.&lt;/p&gt;  &lt;p&gt;Apparently: “For the last several months, a large team of Googlers has been working on a secret project: a next-generation architecture for Google’s web search. It’s the first step in a process that will let us push the envelope on size, indexing speed, accuracy, comprehensiveness and other dimensions. The new infrastructure sits “under the hood” of Google’s search engine, which means that most users won’t notice a difference in search results. But web developers and power searchers might notice a few differences, so we’re opening up a web developer preview to collect feedback.”&lt;/p&gt;  &lt;p&gt;&lt;a title="http://googlewebmastercentral.blogspot.com/2009/08/help-test-some-next-generation.html" href="http://googlewebmastercentral.blogspot.com/2009/08/help-test-some-next-generation.html"&gt;http://googlewebmastercentral.blogspot.com/2009/08/help-test-some-next-generation.html&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-4652428448141598853?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4652428448141598853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4652428448141598853'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/08/new-version-of-google-search-engine.html' title='New version of Google Search Engine'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-6615187991241169966</id><published>2009-08-11T12:49:00.000-07:00</published><updated>2010-03-28T12:50:27.720-07:00</updated><title type='text'>Encrypting your web.config file</title><content type='html'>&lt;p&gt;Ever see a connection string in a configuration file with the Username and Password available to the world?&amp;#160; I know I have, far to many time to be good.&amp;#160; But; did you know that you can quite easily Encrypt and Decrypt this on-the-fly using built in .Net functionality?!?!&amp;#160; Well you can and it’s very easy to do too.&lt;/p&gt;  &lt;h3&gt;Setting up your project&lt;/h3&gt;  &lt;p&gt;First create a simple ASP.NET web application in Visual Studio 2008. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Edit the current web.config file and add a valid connection string:&lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;lt;connectionStrings&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;add name=&amp;quot;MyAppConnection&amp;quot; connectionString=&amp;quot;Server=dubwsdev001;Database=DevDatabase;Integrated Security=false;User Id=xxxxx;PWD=xxxxxxxxx;&amp;quot; /&amp;gt;      &lt;br /&gt;&amp;lt;/connectionStrings&amp;gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;li&gt;Edit the default.aspx file&lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;Add two labels and two button to your form or just copy/paste the following code:&lt;/p&gt;    &lt;p&gt;&amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;div&amp;gt;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:Label ID=&amp;quot;lblStatus&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;br /&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:Label ID=&amp;quot;lblConnection&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;br /&amp;gt; &lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:Button ID=&amp;quot;btnEncrypt&amp;quot; runat=&amp;quot;server&amp;quot; onclick=&amp;quot;EncryptConfig&amp;quot; Text=&amp;quot;Encrypt&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;amp;nbsp;&amp;amp;nbsp;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:Button ID=&amp;quot;btnDecrypt&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;quot;Decrypt&amp;quot; onclick=&amp;quot;DecryptConfig&amp;quot; /&amp;gt; &lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;br /&amp;gt; &lt;/p&gt;    &lt;p&gt;&amp;lt;/div&amp;gt;     &lt;br /&gt;&amp;lt;/form&amp;gt; &lt;/p&gt;    &lt;p&gt;It should look something like the following: &lt;/p&gt;    &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-y8-pSWkI/AAAAAAAAAhE/QF1ElVDenSg/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-y9Z-YMvI/AAAAAAAAAhI/gOoU7bemNn0/image_thumb.png?imgmax=800" width="244" height="236" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;li&gt;Edit the code behind “default.aspx.cs” file to populate the lblConnection text label with the connection string we have in the web.config file.&amp;#160; Do this by adding the following code:&lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;using System.Web.Configuration;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;protected void Page_Load(object sender, EventArgs e)     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string strConnection= WebConfigurationManager.ConnectionStrings[&amp;quot;MyAppConnection&amp;quot;].ConnectionString;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lblConnection.Text = strConnection;      &lt;br /&gt;} &lt;/p&gt;    &lt;p&gt;protected void EncryptConfig(object sender, EventArgs e)     &lt;br /&gt;{ &lt;/p&gt;    &lt;p&gt;} &lt;/p&gt;    &lt;p&gt;protected void DecryptConfig(object sender, EventArgs e)     &lt;br /&gt;{ &lt;/p&gt;    &lt;p&gt;} &lt;/p&gt;    &lt;p&gt;Starting the application should result in the following:&lt;/p&gt;    &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-y9_0-YZI/AAAAAAAAAhM/UPVi9nokoj8/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-y-eS59vI/AAAAAAAAAhQ/09dPb58aO5M/image_thumb1.png?imgmax=800" width="244" height="179" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Encrypt / Decrypt on-the-fly&lt;/h3&gt;  &lt;p&gt;To do this we need 3 private methods .. one to Encrypt the files, one to decrypt the file and one to see if encryption is already in place (i.e. you don’t want to encrypt an already encrypted section).&amp;#160; So we add these to the button methods in the code behind.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;protected void EncryptConfig(object sender, EventArgs e)     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (&lt;strong&gt;IsEncrypted(Request.ApplicationPath)&lt;/strong&gt;)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return;&amp;#160;&amp;#160; // alredy done so ignore &lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160; &lt;strong&gt;EncryptConnString(Request.ApplicationPath);       &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160; btnDecrypt.Enabled = true;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; btnEncrypt.Enabled = false;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; lblStatus.Text = &amp;quot;The connection string is currently is encrypted &amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; lblConnection.Text = WebConfigurationManager.ConnectionStrings[&amp;quot;MyAppConnection&amp;quot;].ConnectionString;       &lt;br /&gt;} &lt;/p&gt;    &lt;p&gt;protected void DecryptConfig(object sender, EventArgs e)     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if &lt;strong&gt;(!IsEncrypted(Request.ApplicationPath)&lt;/strong&gt;)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return;&amp;#160;&amp;#160; // alredy decrypted so ignore &lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;DecryptConnString(Request.ApplicationPath);&lt;/strong&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; btnEncrypt.Enabled = true;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; btnDecrypt.Enabled = false;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; lblStatus.Text = &amp;quot;The connection string is currently is not encrypted!&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; lblConnection.Text = WebConfigurationManager.ConnectionStrings[&amp;quot;MyAppConnection&amp;quot;].ConnectionString; &lt;/p&gt;    &lt;p&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The IsEncrypted, EncryptConnnString and DecryptConString are our methods that do all the work.&amp;#160; Here I’ve implemented them in the page, but there is no reason why it can’t be done in a helper class or within a common framework. &lt;/p&gt;  &lt;h3&gt;IsEncrypted&lt;/h3&gt;  &lt;p&gt;Probably the simplest method to understand the “var config” simply opens the configuration file that is passed from the button press.&amp;#160; The path is noted in the ASP.NET request object in a property called ApplicationPath.&lt;/p&gt;  &lt;p&gt;private static bool IsEncrypted(string strPath)   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var config = &lt;strong&gt;WebConfigurationManager.OpenWebConfiguration(strPath);&lt;/strong&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return &lt;strong&gt;config.GetSection(&amp;quot;connectionStrings&amp;quot;).SectionInformation.IsProtected&lt;/strong&gt;;    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;If the of the Section “connectionStrings” has been encrypted a property called IsProtected is set to true.&amp;#160; remember this is all automatic, you don’t have to write any code to check this! &lt;/p&gt;  &lt;h3&gt;EncryptConnString and DecryptConnString&lt;/h3&gt;  &lt;p&gt;Here is were it gets a little more complicated, as above the OpenWebConfiguration method will return you an instance of the current web.config file. the commend “section.SectionInformation.ProtectSection(&amp;quot;RsaProtectedConfigurationProvider&amp;quot;)” however; actually does all the work.&amp;#160; The provider is already built into the .NET and will give you 128bit encryption on whatever section you have selected.&amp;#160; In this case it’s the “ConnectionStrings” area.&lt;/p&gt;  &lt;p&gt;private static void EncryptConnString(string strPath)   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var config = WebConfigurationManager.OpenWebConfiguration(strPath);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var section = config.GetSection(&amp;quot;connectionStrings&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (section.SectionInformation.IsProtected) return;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;section.SectionInformation.ProtectSection(&amp;quot;RsaProtectedConfigurationProvider&amp;quot;);&lt;/strong&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; config.Save();    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;DecryptConnString is the same as EncryptConnString but calls the UnprotectSection method. &lt;/p&gt;  &lt;p&gt;private static void DecryptConnString(string strPath)   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var config = WebConfigurationManager.OpenWebConfiguration(strPath);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var section = config.GetSection(&amp;quot;connectionStrings&amp;quot;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (!section.SectionInformation.IsProtected) return;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; section.SectionInformation.UnprotectSection();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; config.Save();    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;Run your web application again and press the “Encrypt” button. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-y-nlhBII/AAAAAAAAAhU/h5T2otn07E8/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-y_N8sANI/AAAAAAAAAhY/02ErJrmtPAk/image_thumb2.png?imgmax=800" width="244" height="187" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice that the label now says the connection section has been Encrypted; however the connection string is still read correctly!&amp;#160; Now if you open the web.config file using Visual Studio you’ll see the following: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-y_fGDUdI/AAAAAAAAAhc/Qq2MxQ1I0rM/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-y_3qbNNI/AAAAAAAAAhg/aAYe7Ah1eas/image_thumb3.png?imgmax=800" width="244" height="90" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Lets see a hacker get past that baby!! &lt;/p&gt;  &lt;p&gt;Press “Decrypt” on your application and the web.config will return to : &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-zAbsXSVI/AAAAAAAAAhk/OkV1yv0WOFM/s1600-h/image14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-zAiEoqrI/AAAAAAAAAho/nIlyctiX6vo/image_thumb4.png?imgmax=800" width="244" height="34" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Best of all there is no code to write!!!!!!! &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-6615187991241169966?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6615187991241169966'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6615187991241169966'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/08/encrypting-your-webconfig-file.html' title='Encrypting your web.config file'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh5.ggpht.com/_r_B45UywYok/S6-y9Z-YMvI/AAAAAAAAAhI/gOoU7bemNn0/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-4200880264835981601</id><published>2009-08-06T12:47:00.000-07:00</published><updated>2010-03-28T12:48:07.540-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Using BING Maps in your ASP.NET Applications</title><content type='html'>&lt;p&gt;I was using the Google Maps API last week on a project and realised that the who JavaScript thing was a bit of a pain to debug.&amp;#160; Although it works fine, it’s fast and is easy to use it still gave me pause for thought.&amp;#160; so looking around for an alternative I decided to give the Microsoft offing a quick once around the block.&lt;/p&gt;  &lt;h3&gt;Installation &lt;/h3&gt;  &lt;p&gt;First off you’ll need Visual Studio 2008 to be installed and to down load the &lt;a href="http://dev.live.com/tools/" target="_blank"&gt;Windows Live Tools for Microsoft Visual Studio&lt;/a&gt; which contains all the DLLs you’ll need.&amp;#160; It also comes with other bit and pieces, but this post only relates to the mapping element.&lt;/p&gt;  &lt;p&gt;After saving the file to your local drive execute the WindowsLiveTools.msi.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-yWhe3r4I/AAAAAAAAAgI/8ZfgSkhurx4/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-yXI7gjUI/AAAAAAAAAgM/qQAyNymdQIw/image_thumb.png?imgmax=800" width="244" height="193" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click next and follow all the onscreen prompts.&lt;/p&gt;  &lt;h3&gt;Adding a Map to your site&lt;/h3&gt;  &lt;p&gt;Microsoft have made it very easy to adding a map to your website, once the software has been installed you get a set of new tools in Visual Studio.&lt;/p&gt;  &lt;p&gt;Open up any ASPX Page in design view and select the “Map” icon within the Virtual Earth group on your tool bar:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-yXTkYElI/AAAAAAAAAgQ/MReEZnBjVaE/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-yX-WyANI/AAAAAAAAAgU/K-moLRo3dT4/image_thumb2.png?imgmax=800" width="244" height="224" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Drag this icon to your' page.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-yYueyg4I/AAAAAAAAAgY/-YqPt77zYw4/s1600-h/image17.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-yYxqvpTI/AAAAAAAAAgc/Uvl_xrhlhdc/image_thumb5.png?imgmax=800" width="244" height="227" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Next you need to select a ScriptManager from within the “Ajax Extensions” group and drag this to your page too.&lt;/p&gt;  &lt;p&gt;Press Play to debug your application and make sure it’s working.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-yZxhXZLI/AAAAAAAAAgk/s0IyFU1M3d8/s1600-h/image20.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-yatM9SEI/AAAAAAAAAgo/_dLGslDkuK0/image_thumb6.png?imgmax=800" width="197" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;By default you open up over the North American continent which is not the best for an Irish company.&amp;#160; So to fix this we have to go into the page code behind.&amp;#160; Open up the default.aspx.cs file and add the following code:&lt;/p&gt;  &lt;p&gt;protected void Page_Load(object sender, EventArgs e)   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Map1.Center.Latitude = 53.33306;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Map1.Center.Longitude= -6.24889;    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;Press Play again and you should see the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-ybOaeoGI/AAAAAAAAAgs/oS7AtqTAusE/s1600-h/image23.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-ybVXx44I/AAAAAAAAAgw/pKpsk871rok/image_thumb7.png?imgmax=800" width="181" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;Doing Directions&lt;/h3&gt;  &lt;p&gt;One of the key advantages to mapping is the ability to get directions from one place to another.&amp;#160; Microsoft have made this really, really easy by just creating a generic list of string with valid addresses.&lt;/p&gt;  &lt;p&gt;Create two text boxes on the page with a submit button.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-ycNhLsDI/AAAAAAAAAg0/YpWaS5Z1yOU/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-ycZ3zaBI/AAAAAAAAAg4/lcCY6u1h92A/image_thumb1.png?imgmax=800" width="192" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In the code behind add the following to the on click event for the button.&lt;/p&gt;  &lt;p&gt;using Microsoft.Live.ServerControls.VE; &lt;/p&gt;  &lt;p&gt;protected void btnRoute_Click(object sender, EventArgs e)   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RouteOptions options = new RouteOptions();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; options.SetBestMapView = true;&amp;#160; // will zoom into the route    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;string&amp;gt; address = new List&amp;lt;string&amp;gt;();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; address.Add(tbxFrom.Text);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; address.Add(tbxTo.Text);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Map1.GetDirections(address, options);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;Press play on the application; type the following into the fields and press the “Route” button:&lt;/p&gt;  &lt;p&gt;From: East Point Business Park, Dublin, Ireland   &lt;br /&gt;To:&amp;#160;&amp;#160;&amp;#160;&amp;#160; O’Connoll Street, Dublin, Ireland&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-ydJYRxLI/AAAAAAAAAg8/4pcS6pbmN1M/s1600-h/image26.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-ydv1x9LI/AAAAAAAAAhA/qHrCTlREFOw/image_thumb8.png?imgmax=800" width="174" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here is the result….&amp;#160; simple and easy…&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-4200880264835981601?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4200880264835981601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4200880264835981601'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/08/using-bing-maps-in-your-aspnet.html' title='Using BING Maps in your ASP.NET Applications'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/S6-yXI7gjUI/AAAAAAAAAgM/qQAyNymdQIw/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-1840311439486617673</id><published>2009-07-07T12:45:00.000-07:00</published><updated>2010-03-28T12:46:17.710-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Generating SQL Diagrams using MS Visio 2003</title><content type='html'>&lt;p&gt;You can build a set of database diagrams using Visio 2003 SP1.&amp;#160; It’s not the best solution but it does work to some extent.&amp;#160; Like all reverse engineering tools it assumes that you have implement some form of relationship mapping and constraints in within the database.&lt;/p&gt;  &lt;p&gt;1) Open Visio and Select “Database/Database Model Diagram”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-x6SgwEXI/AAAAAAAAAe4/gKvwjXwLpoY/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-x6m1WSAI/AAAAAAAAAe8/uWGe1rZqdqg/image_thumb1.png?imgmax=800" width="244" height="184" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;2) From the menu choose Database / Reverse Engineer &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-x6-h1-FI/AAAAAAAAAfA/ymSVwnvHSwM/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-x7dFexII/AAAAAAAAAfE/pV5mT2ceOUQ/image_thumb2.png?imgmax=800" width="244" height="154" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;3) Set up your connection to the database&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-x7hGo7iI/AAAAAAAAAfI/RDYwBNdK91Y/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-x8OEdr_I/AAAAAAAAAfM/5IR3r5fF-e4/image_thumb3.png?imgmax=800" width="244" height="159" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;choose SQL Server / click New.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-x8Z9s_RI/AAAAAAAAAfQ/xm1fxB3dWCE/s1600-h/image14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-x8_SUVxI/AAAAAAAAAfU/ll2k0MmeEm8/image_thumb4.png?imgmax=800" width="244" height="185" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select System Data Source and click Next.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-x9dzBUUI/AAAAAAAAAfY/MtteEgsgPc4/s1600-h/image17.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-x9wuB49I/AAAAAAAAAfc/XqdUtWZntc0/image_thumb5.png?imgmax=800" width="244" height="183" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select SQL Server and click Next and Finish&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-x-Xp2gTI/AAAAAAAAAfg/KFglkltsGWo/s1600-h/image20.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-x-0-uwuI/AAAAAAAAAfk/OBTp-y6WJOQ/image_thumb6.png?imgmax=800" width="244" height="173" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Enter a meaningful name and enter the DB Server you want to work against (in this case Dubwsdev001), click Next and Next again to use Network Authentication.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-x_DpSpgI/AAAAAAAAAfo/UrbfCper5Xk/s1600-h/image23.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-x_yh7wzI/AAAAAAAAAfs/rKf_K5hRXKg/image_thumb7.png?imgmax=800" width="244" height="176" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select your database and click Next and Finish and then OK.&amp;#160; Click Next at the Reverse Engineering Wizard dialogue.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-yAJm_4VI/AAAAAAAAAfw/bKSQqEw03Es/s1600-h/image26.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-yA5Sj0AI/AAAAAAAAAf0/NmrLg8kxib0/image_thumb8.png?imgmax=800" width="244" height="159" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select the times you want to reverse engineer and click Next.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-yBEd4fmI/AAAAAAAAAf4/Qqx8CG2SfwI/s1600-h/image29.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-yBhjhVkI/AAAAAAAAAf8/19ytPeQi5MU/image_thumb9.png?imgmax=800" width="244" height="160" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select the Tables/Views you want to work with and click Finish.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-yB01ca9I/AAAAAAAAAgA/bWd7D0OeJ88/s1600-h/image32.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-yCTarb7I/AAAAAAAAAgE/rVPhEbBgvk8/image_thumb10.png?imgmax=800" width="244" height="226" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You should now see the table in your Visio page.&amp;#160; &lt;/p&gt;  &lt;p&gt;Remember that this reflects the table structure exactly, so if there are lots of columns, you’ll see lots of columns.&amp;#160; After a few hours playing around you’ll probably find doing it by hand is easier.&lt;/p&gt;  &lt;h3&gt;Alternative Solution&lt;/h3&gt;  &lt;p&gt;You can also use SQL 2005 or 2008 Management Studio to create database diagrams, however we don’t have a copy of that here.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-1840311439486617673?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1840311439486617673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1840311439486617673'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/07/generating-sql-diagrams-using-ms-visio.html' title='Generating SQL Diagrams using MS Visio 2003'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/S6-x6m1WSAI/AAAAAAAAAe8/uWGe1rZqdqg/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-7278297920454074891</id><published>2009-06-18T12:43:00.000-07:00</published><updated>2010-03-28T12:43:17.612-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>WCF on Multi Host Servers</title><content type='html'>&lt;p&gt;I ran into this problem today when I was working on a WCF project.&amp;#160; A project which was working fine on my machine start producing the error “This collection already contains an address with scheme http.&amp;#160; There can be at most one address per scheme in this collection. Parameter name: item&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-xUrO_WsI/AAAAAAAAAew/J4U56YfztPM/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-xVHXY1OI/AAAAAAAAAe0/jVtYL-dmzrM/image_thumb.png?imgmax=800" width="244" height="167" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="left"&gt;Turns out that because the server was hosting a number of different sites using different Host Headers WCF needs to know which of the hosts to respond too.&amp;#160; You can do this by added the following to the services web.config file.&lt;/p&gt;  &lt;p&gt;&amp;#160; &amp;lt;system.serviceModel&amp;gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;serviceHostingEnvironment aspNetCompatibilityEnabled=&amp;quot;true&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;baseAddressPrefixFilters&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;add prefix=&amp;quot;http://www.blahblah.com&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/baseAddressPrefixFilters&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/serviceHostingEnvironment&amp;gt; &lt;/p&gt;  &lt;p align="left"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ……&lt;/p&gt;&amp;#160;&amp;#160; &amp;lt;/system.serviceModel&amp;gt;  &lt;br /&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;That tells the service to only respond on the specific header.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-7278297920454074891?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/7278297920454074891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/7278297920454074891'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/06/wcf-on-multi-host-servers.html' title='WCF on Multi Host Servers'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/S6-xVHXY1OI/AAAAAAAAAe0/jVtYL-dmzrM/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-899740564224485602</id><published>2009-06-17T12:41:00.000-07:00</published><updated>2010-03-28T12:41:51.463-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Self signing your server for SSL</title><content type='html'>&lt;p&gt;I’ve been playing around with WCF and one of the problem areas is that our secure servers use a reverse-proxy configuration to route requests for web services.&amp;#160; This is all fine for old web services; however WCF is a little more particular with it’s requirements.&amp;#160; The reason for this is that the SSL Certificate does not actually exist on the Secure Server, it exists on the Proxy server, therefore when WCF starts it brings up the error saying “SSL is not supported”.&amp;#160; To resolve this we need to provide the server with a mock certificate using the same domain name as that used by the Proxy server.&lt;/p&gt;  &lt;p&gt;To create a local mock SSL certificate for your development machine is quite easy and is also very useful to have if you are doing testing.&lt;/p&gt;  &lt;h3&gt;Installation&lt;/h3&gt;  &lt;ol&gt;   &lt;li&gt;Download the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=56fc92ee-a71a-4c73-b628-ade629c89499&amp;amp;DisplayLang=en" target="_blank"&gt;Internet Information Services (IIS) 6.0 Resource Kit Tools&lt;/a&gt; from the Microsoft site. &lt;/li&gt;    &lt;li&gt;Run the installation&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-w63UupvI/AAAAAAAAAeA/2KKbw5b7sp8/s1600-h/image2.png"&gt;&amp;#160; &lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-w7cyJTgI/AAAAAAAAAeE/YLjjNeDJOVM/image_thumb.png?imgmax=800" width="244" height="188" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-w7ut340I/AAAAAAAAAeI/HnrS0whOdek/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-w8B3lgVI/AAAAAAAAAeM/TdvxF8LaQfQ/image_thumb1.png?imgmax=800" width="244" height="188" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;3.&amp;#160; Choose a complete install and follow all the instructions until it’s finished.&lt;/p&gt;  &lt;p&gt;4.&amp;#160; Now you go to your Start/Programs/IIS Resources/SelfSSL/SelfSSL.&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-w8eFQIDI/AAAAAAAAAeQ/a_q-eO1wRP8/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-w88x9VEI/AAAAAAAAAeU/0JMhF1wr_RY/image_thumb2.png?imgmax=800" width="244" height="125" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;5.&amp;#160;&amp;#160; You need to work out your Site ID and the easiest way to get this is to use IIS Admin right click the website properties and go to Logging properties in the website Tab and look at the Log File name below the Site ID is “1”.&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-w9QhGS6I/AAAAAAAAAeY/QLYfEumI9Yk/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-w9_N8D1I/AAAAAAAAAec/fl5rzKrH1Ec/image_thumb3.png?imgmax=800" width="244" height="236" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;6.&amp;#160;&amp;#160; Enter the command “SELFSSL.EXE /S:1” and confirm “Y”.&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-w-RGBw8I/AAAAAAAAAeg/YrRMoGvqOAk/s1600-h/image14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-w-moY3NI/AAAAAAAAAek/7YUyA9haPGU/image_thumb4.png?imgmax=800" width="244" height="125" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;7.&amp;#160;&amp;#160; Your site is now activated to use SSL.&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-w_YLZCYI/AAAAAAAAAeo/p5goErf0ve4/s1600-h/image17.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-w_lo2dDI/AAAAAAAAAes/i9gEXGm3BMw/image_thumb5.png?imgmax=800" width="244" height="134" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-899740564224485602?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/899740564224485602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/899740564224485602'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/06/self-signing-your-server-for-ssl.html' title='Self signing your server for SSL'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh6.ggpht.com/_r_B45UywYok/S6-w7cyJTgI/AAAAAAAAAeE/YLjjNeDJOVM/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-6107372521208601816</id><published>2009-06-08T02:42:00.001-07:00</published><updated>2009-06-08T02:42:52.093-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>SharePoint Site Templates</title><content type='html'>&lt;p&gt;I was recently asked to change the basic template used when creating a site for the first time from a Blank Site to Team Site.&amp;#160; As the site was created using a PowerShell script it required finding out which code should be used for the sitetemplate option in the STSADM command.&lt;/p&gt;  &lt;p&gt;# Create new WebSite   &lt;br /&gt;stsadm.exe -o createsite -url $spwebsite -title &amp;quot;My Team Site&amp;quot; -ownerlogin entirl\$username -owneremail sharepointadmin@enterprise-ireland.com &lt;strong&gt;-sitetemplate STS#1&lt;/strong&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2" width="400" border="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Friendly Name&lt;/td&gt;        &lt;td valign="top" width="200"&gt;Template&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Team Site&lt;/td&gt;        &lt;td valign="top" width="200"&gt;STS#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Blank Site&lt;/td&gt;        &lt;td valign="top" width="200"&gt;STS#1&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Document Workspace&lt;/td&gt;        &lt;td valign="top" width="200"&gt;STS#2&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Wiki Site&lt;/td&gt;        &lt;td valign="top" width="200"&gt;WIKI#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Blog&lt;/td&gt;        &lt;td valign="top" width="200"&gt;BLOG#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Basic Meeting Workspace&lt;/td&gt;        &lt;td valign="top" width="200"&gt;MPS#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Blank Meeting Workspace&lt;/td&gt;        &lt;td valign="top" width="200"&gt;MPS#1&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Decision Meeting Workspace&lt;/td&gt;        &lt;td valign="top" width="200"&gt;MPS#2&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Social Meeting Workspace&lt;/td&gt;        &lt;td valign="top" width="200"&gt;MPS#3&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Multipage Meeting Workspace&lt;/td&gt;        &lt;td valign="top" width="200"&gt;MPS#4&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Document Center&lt;/td&gt;        &lt;td valign="top" width="200"&gt;BDR#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Records Center&lt;/td&gt;        &lt;td valign="top" width="200"&gt;OFFILE#1&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Personalization Site&lt;/td&gt;        &lt;td valign="top" width="200"&gt;SPSMSITE#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Site Directory&lt;/td&gt;        &lt;td valign="top" width="200"&gt;SPSITES#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Report Center&lt;/td&gt;        &lt;td valign="top" width="200"&gt;SPREPORTCENTER#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Search Center with Tabs&lt;/td&gt;        &lt;td valign="top" width="200"&gt;SRCHCEN#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Search Center&lt;/td&gt;        &lt;td valign="top" width="200"&gt;SRCHCENTERLITE#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Publishing Site&lt;/td&gt;        &lt;td valign="top" width="200"&gt;CMSPUBLISHING#0&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Publishing Site with Workflow&lt;/td&gt;        &lt;td valign="top" width="200"&gt;BLANKINTERNET#2&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;News Site&lt;/td&gt;        &lt;td valign="top" width="200"&gt;SPSNHOME#0&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-6107372521208601816?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devrichardagreene.blogspot.com/feeds/6107372521208601816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7889773289404691484&amp;postID=6107372521208601816' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6107372521208601816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6107372521208601816'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/06/sharepoint-site-templates.html' title='SharePoint Site Templates'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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-7889773289404691484.post-1551159516992522360</id><published>2009-06-06T12:38:00.000-07:00</published><updated>2010-03-28T12:38:24.089-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>Set of very interesting Webcasts</title><content type='html'>&lt;p&gt;I was doing some surfing over the weekend and came across an very interesting site called &lt;a href="http://www.dimecasts.net/" target="_blank"&gt;Dime Casts&lt;/a&gt;.&amp;#160; It’s a selection of tutorials that don’t take longer than 10 minutes.&lt;/p&gt;  &lt;p&gt;Some of the topics covered are very interesting in terms of good .Net programming techniques for using Design Patterns.&amp;#160; Check it out if you have a few minutes.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-1551159516992522360?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1551159516992522360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1551159516992522360'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/06/set-of-very-interesting-webcasts_06.html' title='Set of very interesting Webcasts'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-4093688878875705391</id><published>2009-06-02T03:04:00.001-07:00</published><updated>2009-06-02T03:04:57.574-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Set of very interesting Webcasts</title><content type='html'>&lt;p&gt;I was doing some surfing over the weekend and came across an very interesting site called &lt;a href="http://www.dimecasts.net/" target="_blank"&gt;Dime Casts&lt;/a&gt;.&amp;#160; It’s a selection of tutorials that don’t take longer than 10 minutes.&lt;/p&gt;  &lt;p&gt;Some of the topics covered are very interesting in terms of good .Net programming techniques for using Design Patterns.&amp;#160; Check it out if you have a few minutes.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-4093688878875705391?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devrichardagreene.blogspot.com/feeds/4093688878875705391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7889773289404691484&amp;postID=4093688878875705391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4093688878875705391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/4093688878875705391'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/06/set-of-very-interesting-webcasts.html' title='Set of very interesting Webcasts'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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-7889773289404691484.post-1170610683438418675</id><published>2009-05-27T12:36:00.000-07:00</published><updated>2010-03-28T12:37:22.131-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>Enable Anonymous Access on a SharePoint Site</title><content type='html'>&lt;p&gt;Today I was working on a SharePoint site that needed to be accessed by people outside of our domain.&amp;#160; Assuming you have your site created in the stand way, Users would normally access it via the NTML (windows Challenge/Response) protocol, i.e. SharePoint knows who you are from your domain login.&amp;#160; This was not possible for my Users as they would not be allowed have usernames on our domain.&amp;#160; Therefore the solution was to enable Anonymous access to the site.&lt;/p&gt;  &lt;p&gt;1) Access SharePoint Central Administration and select Application Management from the left hand links.&lt;/p&gt;  &lt;p&gt;2) Under Application Security select Authentication providers, then select the Web Application using the drop down on the tool bar.&amp;#160; In my case it was “SharePointPortal – 80”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-v4dZdS9I/AAAAAAAAAdg/7Tpa-E_XuCE/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-v47rlpqI/AAAAAAAAAdk/1lr5VM8_JHw/image_thumb.png?imgmax=800" width="244" height="179" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;3) Click on the” Default” zone link and tick the “Enable anonymous access” check box and press Save.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-v5m7Ml9I/AAAAAAAAAdo/ee-onZmQr0M/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-v6Hgo60I/AAAAAAAAAds/gwLtF-HT7G0/image_thumb1.png?imgmax=800" width="244" height="191" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This enables Anonymous access on the Server, however each site still needs to be configured to use this setting.&amp;#160; This prevents people from making information available to external sources in error.&lt;/p&gt;  &lt;p&gt;4) On the specific site login as the SharePoint Administrator or another User who has assess to the SharePoint Site Settings menu.&amp;#160; From the SharePoint Site Setting screen select “Advanced Permissions”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-v6loaP_I/AAAAAAAAAdw/ri9111Ys7co/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-v7BGFdsI/AAAAAAAAAd0/SwD_1C-DICo/image_thumb2.png?imgmax=800" width="244" height="191" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;5) From the Advanced Permissions page select Settings/Anonymous Access from the toolbar menu.&amp;#160; When that screen appears you can select the level of access an anonymous user can see information.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-v7hPlK6I/AAAAAAAAAd4/CIoH5QNcy-Y/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-v8WXTu2I/AAAAAAAAAd8/DLB2M0L0y_o/image_thumb3.png?imgmax=800" width="244" height="191" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The options are self explanatorily and in my case Entire Web site was the correct option.&amp;#160; Save this option by Clicking OK.&lt;/p&gt;  &lt;p&gt;The site should now be accessible to external Users to view.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-1170610683438418675?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1170610683438418675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1170610683438418675'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/05/enable-anonymous-access-on-sharepoint.html' title='Enable Anonymous Access on a SharePoint Site'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/S6-v47rlpqI/AAAAAAAAAdk/1lr5VM8_JHw/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-9139689506825829239</id><published>2009-05-26T12:33:00.000-07:00</published><updated>2010-03-28T12:33:22.365-07:00</updated><title type='text'>Google killer? Probably not</title><content type='html'>&lt;p&gt;Keeping track of new developments on the net is never easy, there is so much going on that usually its all just white noise.&amp;#160; Every now and again you do come across something interesting so I figured I’d do a post in case someone else gets some ideas.&lt;/p&gt;  &lt;p&gt;It was all over the recent Tech news that there was a new browser in town called &lt;a title="http://www.wolframalpha.com/" href="http://www.wolframalpha.com/" target="_blank"&gt;Wolfram Alpha&lt;/a&gt;.&amp;#160; This takes a different approach from Google in two ways. First is that it’s a closed system i.e. only information that is vetted by experts is allowed in, which will supposedly increase accuracy. Second is that it takes real English questions like “population of Ireland in 2008” or “convert 100 euro to US dollar”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-u_3X2LcI/AAAAAAAAAdY/PoRaBNj4_2Q/s1600-h/image3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-vAZXLR8I/AAAAAAAAAdc/b_OkSV_MyF0/image_thumb1.png?imgmax=800" width="381" height="359" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Having played with it for a while I’m not really impressed, but it’s an interesting idea.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-9139689506825829239?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/9139689506825829239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/9139689506825829239'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/05/google-killer-probably-not.html' title='Google killer? Probably not'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/S6-vAZXLR8I/AAAAAAAAAdc/b_OkSV_MyF0/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-3410735790961745172</id><published>2009-05-26T12:31:00.000-07:00</published><updated>2010-03-28T12:31:41.802-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>Error running Powershell Scripts</title><content type='html'>&lt;p&gt;Now that I’m generating Sharepoint sites using Powershell scripts I noticed an error appearing on the servers.&lt;/p&gt;  &lt;p&gt;&amp;quot;File xxx cannot be loaded because the execution of scripts is disabled on this system. Please see &amp;quot;get-help about_signing&amp;quot; for more details.&amp;quot;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-umv86IbI/AAAAAAAAAdQ/0ENmKYanAmQ/s1600-h/image4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-unCS7UHI/AAAAAAAAAdU/1HHHsWSEsgk/image_thumb2.png?imgmax=800" width="454" height="225" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Turns out that for security reasons running scripts this way is disabled by default.&amp;#160; Check out &lt;a href="http://www.itexperience.net/2008/07/18/file-cannot-be-loaded-because-the-execution-of-scripts-is-disabled-on-this-system-error-in-powershell/" target="_blank"&gt;this blog posting&lt;/a&gt; for more information on the various options available.&lt;/p&gt;  &lt;h3&gt;Solution&lt;/h3&gt;  &lt;p&gt;From within Powershell type the command “&lt;strong&gt;Set-ExecutionPolicy Unrestricted&lt;/strong&gt;” and then “exit”.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-3410735790961745172?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/3410735790961745172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/3410735790961745172'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/05/error-running-powershell-scripts.html' title='Error running Powershell Scripts'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh3.ggpht.com/_r_B45UywYok/S6-unCS7UHI/AAAAAAAAAdU/1HHHsWSEsgk/s72-c/image_thumb2.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2418697014877232275</id><published>2009-05-01T12:29:00.000-07:00</published><updated>2010-03-28T12:30:21.483-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>SharePoint Development – Creating a webpart</title><content type='html'>&lt;p&gt;This is the first of many posts which will try to put together the steps you need to develop within the SharePoint platform.&amp;#160; First off it I’ll describe creating a simple WebPart that puts a message on the page.&amp;#160; &lt;/p&gt;  &lt;h3&gt;Creating the solution&lt;/h3&gt;  &lt;p&gt;To help with the general issue of creating your Visual Studio 2008 solution we use a handy tool called STSDEV.&amp;#160; More information on this can be found on the projects &lt;a href="http://stsdev.codeplex.com/" target="_blank"&gt;homepage&lt;/a&gt; on &lt;a href="http://www.codeplex.com/" target="_blank"&gt;Codeplex&lt;/a&gt;.&amp;#160; &lt;/p&gt;  &lt;p&gt;Browse to c:\Program Files\StsDev\ and run StsDev.exe.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-uM2R-Q6I/AAAAAAAAAcQ/qhWNnJ0cTw4/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-uNesNqhI/AAAAAAAAAcU/EQudTAjdJXI/image_thumb.png?imgmax=800" width="244" height="98" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Enter the name of the solution you want to create, in this example I’ll use “EIWebPart”.&amp;#160; Browse to D:\Development\EIPortal\ as the Parent directory.&amp;#160; Select C:\development\eiportal\eiportal.snk as the Signing Key (you can get the latest version of this from SourceSafe).&amp;#160; Select “Web Part Solution (C# Assembly) as the solution type and “Visual Studio 2005 with .Net 3.0” as the version type.&amp;#160; “Why?” I hear you ask?&amp;#160; Well because the version of STSDEV on the VM is not working for some reason and I’ve not had a chance to find out why. yet….&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-uNrxpEUI/AAAAAAAAAcY/2TDJHg5rHI4/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-uOLPs7fI/AAAAAAAAAcc/s7LgODDAbFE/image_thumb1.png?imgmax=800" width="244" height="56" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;All going well, you should see this message.&lt;/p&gt;  &lt;h3&gt;Working in Visual Studio&lt;/h3&gt;  &lt;p&gt;Browse to the location shown by STSDEV and open the solution file, allowing for the usual conversion questions for an upgrade to Visual Studio 2008.&amp;#160; The conversion should happen without any errors.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-uOspcnwI/AAAAAAAAAcg/Ua_wpfXWEhk/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-uO0_rwXI/AAAAAAAAAck/MGeMCHA444c/image_thumb2.png?imgmax=800" width="244" height="209" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You’ll end up with a solution with the following structure.&amp;#160; This structure is very important to sharePoint development as it exactly matches the “12” (aka. “Hive” or “12 Hive”) directory on the server.&amp;#160; The various XML files are also very important as these are used when building and deploying solution.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;feature.xml – contains the link to the webparts file, version numbers and feature information for the solution. &lt;/li&gt;    &lt;li&gt;webparts.xml – contains the links to the various webparts in our feature. &lt;/li&gt;    &lt;li&gt;CustomWebPart1.cs is the code file containing all our work.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;We only want one webpart in our solution to I remove from the feature.xml and webparts.xml all references to CustomWebpart2.cs.&amp;#160; Delete the CustomWebPart2.cs and CustomWebPart2.webpart files.&lt;/p&gt;  &lt;h5&gt;CustomWebPart1.cs&lt;/h5&gt;  &lt;p&gt;Is a very simple file, it simply adds a able to the page and fills it with the text “Hello”.&lt;/p&gt;  &lt;p&gt;protected override void CreateChildControls() {   &lt;br /&gt;&amp;#160; Label lblHello = new Label();    &lt;br /&gt;&amp;#160; lblHello.Text = &amp;quot;Hello&amp;quot;;    &lt;br /&gt;&amp;#160; Controls.Add(lblHello);    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;Webparts work and a coded exactly the same as ASPX files, the only exception is that you can’t use the design pallet.&amp;#160; That means you can drag a Text Box from the Tools and have VS create the code for you, you need to hand code this.&amp;#160; My advice is to keep your webparts simple and avoid anything to crazy like messing with viewstate or late data binding.&lt;/p&gt;  &lt;h5&gt;feature.xml&lt;/h5&gt;  &lt;p&gt;This feature file contains the information about your feature, it’s name a description, version number etc.&amp;#160; If lets as your feature contained lots of different parts, each part would have an entry in the ElementManifests section.&lt;/p&gt;  &lt;p&gt;&amp;lt;Feature   &lt;br /&gt;&amp;#160; Id=&amp;quot;6FA7C22C-52A7-4A46-B944-44E5E7FECE2B&amp;quot;    &lt;br /&gt;&amp;#160; Title=&amp;quot;A sample feature: EIWebPart&amp;quot;    &lt;br /&gt;&amp;#160; Description=&amp;quot;This SharePoint solution was created by the STSDEV utility (&lt;a href="http://codeplex.com/stsdev)&amp;quot;"&gt;http://codeplex.com/stsdev)&amp;quot;&lt;/a&gt;    &lt;br /&gt;&amp;#160; Version=&amp;quot;1.0.0.0&amp;quot;    &lt;br /&gt;&amp;#160; Scope=&amp;quot;Site&amp;quot;    &lt;br /&gt;&amp;#160; Hidden=&amp;quot;false&amp;quot;    &lt;br /&gt;&amp;#160; ImageUrl=&amp;quot;EIWebPart\AfricanPith32.gif&amp;quot; xmlns=&amp;quot;&lt;a href="http://schemas.microsoft.com/sharepoint/&amp;quot;"&gt;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/a&gt;&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;ElementManifests&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ElementManifest    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Location=&amp;quot;WebParts.xml&amp;quot; /&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ElementFile    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Location=&amp;quot;WebParts\CustomWebPart1.webpart&amp;quot; /&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;/ElementManifests&amp;gt;    &lt;br /&gt;&amp;lt;/Feature&amp;gt; &lt;/p&gt;  &lt;p&gt;I’m not going to worry about changing anything here, I’m sure you get the idea. &lt;/p&gt;  &lt;h5&gt;WebParts.xml&lt;/h5&gt;  &lt;p&gt;Again a simple file that just points to each webpart contained in the feature.&lt;/p&gt;  &lt;p&gt;&amp;lt;Elements xmlns=&amp;quot;&lt;a href="http://schemas.microsoft.com/sharepoint/&amp;quot;"&gt;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/a&gt;&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;Module Name=&amp;quot;EIWebPart&amp;quot; List=&amp;quot;113&amp;quot; Url=&amp;quot;_catalogs/wp&amp;quot; Path=&amp;quot;WebParts&amp;quot; RootWebOnly=&amp;quot;True&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;File Url=&amp;quot;CustomWebPart1.webpart&amp;quot; Type=&amp;quot;GhostableInLibrary&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Property Name=&amp;quot;Group&amp;quot; Value=&amp;quot;EIWebPart&amp;quot; /&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/File&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;/Module&amp;gt;    &lt;br /&gt;&amp;lt;/Elements&amp;gt; &lt;/p&gt;  &lt;h5&gt;CustomWebPart1.webpart&lt;/h5&gt;  &lt;p&gt;This file is one to watch, it contains all the information needed for the user to interact with the webpart. &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;lt;webParts&amp;gt;   &lt;br /&gt;&amp;#160; &amp;lt;webPart xmlns=&amp;quot;&lt;a href="http://schemas.microsoft.com/WebPart/v3&amp;quot;"&gt;http://schemas.microsoft.com/WebPart/v3&amp;quot;&lt;/a&gt;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;metaData&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;type name=&amp;quot;EIWebPart.CustomWebPart1, EIWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=eb8e38decd6217c5&amp;quot; /&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;importErrorMessage&amp;gt;Error importing Web Part&amp;lt;/importErrorMessage&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/metaData&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;data&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;properties&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;property name=&amp;quot;Title&amp;quot; type=&amp;quot;string&amp;quot;&amp;gt;Default title for CustomWebPart1&amp;lt;/property&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;property name=&amp;quot;Description&amp;quot; type=&amp;quot;string&amp;quot;&amp;gt;A demo Web Part created by stsdev&amp;lt;/property&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;property name=&amp;quot;ChromeState&amp;quot; type=&amp;quot;chromestate&amp;quot;&amp;gt;Normal&amp;lt;/property&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;property name=&amp;quot;AllowZoneChange&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt;True&amp;lt;/property&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;property name=&amp;quot;AllowHide&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt;True&amp;lt;/property&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;property name=&amp;quot;ExportMode&amp;quot; type=&amp;quot;exportmode&amp;quot;&amp;gt;All&amp;lt;/property&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/properties&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/data&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;/webPart&amp;gt;    &lt;br /&gt;&amp;lt;/webParts&amp;gt; &lt;/p&gt;  &lt;p&gt;You get certain properties by default but you can add other is you want.&amp;#160; A good example would be if you wanted to know which Database to connect to, you may have a &amp;lt;property name=&amp;quot;DB&amp;quot; type=&amp;quot;string&amp;quot;&amp;gt;DevWebCDB&amp;lt;/property&amp;gt; entry in this file.&amp;#160; While in your C# file you have a public property called DB {get; set;} which your code can use.&amp;#160; But the SharePoint admin can use the SharePoint UI to change this value to anything else later.&amp;#160; This is very handy, but out of scope of what I’m trying to do at the moment.&lt;/p&gt;  &lt;h3&gt;Ready to go!&lt;/h3&gt;  &lt;p&gt;All you need to do now is compile the solution, so your configuration should be set to “DebugBuild”.&amp;#160; If everything is building correctly you only need to change this to “DebugDeploy” and build the solution again to place your feature into the servers “12 Hive” directory.&amp;#160; Cool or what!!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-uPVMdFhI/AAAAAAAAAco/fragRJgdoFc/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-uPmWUYhI/AAAAAAAAAcs/7g3gsq4WBO0/image_thumb3.png?imgmax=800" width="244" height="73" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you look in the output window you’ll see a whole bunch of STSAdmin commands which is Visual Studio building and then deploying your feature.&amp;#160; You could do this manually, but if VS does all the work anyway, what’s the point of that?&lt;/p&gt;  &lt;p&gt;Browse to one of the sites on your VM.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-uQFqaHtI/AAAAAAAAAcw/no3vdQxvres/s1600-h/image17.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-uQiuX4rI/AAAAAAAAAc0/8xdbbyBViiA/image_thumb5.png?imgmax=800" width="244" height="84" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select “Site Actions” / “Site Settings” from the control menu.&amp;#160; Then select “Site collection Features” on the page. You’ll see that on the last column on the right hand side.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-uRM7nAdI/AAAAAAAAAc4/oMeafAUfXeI/s1600-h/image14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-uRZ-MT2I/AAAAAAAAAc8/aCGDRx08xlA/image_thumb4.png?imgmax=800" width="244" height="55" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;An here we go, our new webpart has been added as a resource that an be used by any site collection.&amp;#160; Click “Activate”.&amp;#160; Then browse back to the Americas home page.&amp;#160; &lt;/p&gt;  &lt;p&gt;Select “Site Actions”/”Edit Page” and click “Add Webpart” at the top of the first Web Part Zone.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-uR0RliNI/AAAAAAAAAdA/oJQ-4SUQQv8/s1600-h/image23.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-uSUGt-uI/AAAAAAAAAdE/UFYvFL508ns/image_thumb7.png?imgmax=800" width="238" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Scroll down a bit and you’ll see our webpart, click the check box next to it and click “Add”, then “Exit Page Edit”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-uS8pwgzI/AAAAAAAAAdI/SdWXtzKR0Qc/s1600-h/image26.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-uTOEo2mI/AAAAAAAAAdM/tm2xxaMC87s/image_thumb8.png?imgmax=800" width="244" height="86" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The Webpart should appear on the top of the page.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2418697014877232275?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2418697014877232275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2418697014877232275'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/05/sharepoint-development-creating-webpart.html' title='SharePoint Development – Creating a webpart'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh6.ggpht.com/_r_B45UywYok/S6-uNesNqhI/AAAAAAAAAcU/EQudTAjdJXI/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-1326902791682006502</id><published>2009-04-24T12:27:00.000-07:00</published><updated>2010-03-28T12:27:24.663-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Short Rant on StringBuilder and String</title><content type='html'>&lt;p&gt;I’ve been running into lots of code which seems to be using Strings to build up HTML or Error Messages.&amp;#160; Unfortunately there is lots of inconsistency in the way it’s been done, but for anyone interested here is my take on it.&amp;#160; First off let me say any hard coding HTML into a code behind is generally a bad idea (don’t get me wrong I’ve done it myself lots of time) so try to avoid it at much as possible.&amp;#160; If however you are unable to avoid it, please review the examples below and try to keep to using the “Good” technique.&lt;/p&gt;  &lt;h3&gt;The Good &lt;/h3&gt;  &lt;p&gt;Here is a reasonably good example of code for building HTML in a code behind if you can’t avoid it.&amp;#160; Using StringBuilder is faster and better suited for concatenation than the primitive String type.&amp;#160; Also using the AppendFormat function allows you to use the {#} place mark which ensures your value goes into the correct location, making the string far more readable and maintainable.&lt;/p&gt;  &lt;p&gt;StringBuilder sbTemp = new StringBuilder();   &lt;br /&gt;sbTemp.AppendFormat(&amp;quot;&amp;lt;a href=\”&lt;a href="mailto:{0"&gt;mailto:{0&lt;/a&gt;}\”&amp;gt;{1}&amp;lt;/a&amp;gt;&amp;quot;,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ConfigurationManager.AppSettings[&amp;quot;IT_EMAIL&amp;quot;],     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ConfigurationManager.AppSettings[&amp;quot;IT_EMAIL&amp;quot;]);    &lt;br /&gt;litITEmail.Text = sbTemp.ToString();&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;The Bad&lt;/h3&gt;  &lt;p&gt;Here is a bad example of the same code using String Builder.&amp;#160; although it will accomplish the same goal as above it requires more code and is much more difficult to read or maintain.   &lt;br /&gt;sbTemp.Append(&amp;quot;&amp;lt;a href=\&amp;quot;mailto:&amp;quot;);    &lt;br /&gt;sbTemp.Append(ConfigurationManager.AppSettings[&amp;quot;IT_EMAIL&amp;quot;]);    &lt;br /&gt;sbTemp.Append(&amp;quot;\&amp;quot;&amp;gt;&amp;quot;);    &lt;br /&gt;sbTemp.Append(ConfigurationManager.AppSettings[&amp;quot;IT_EMAIL&amp;quot;]);    &lt;br /&gt;sbTemp.Append(&amp;quot;&amp;lt;/a&amp;gt;&amp;quot;);    &lt;br /&gt;litITEmail.Text = sbTemp.ToString(); &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;The Down Right Ugly (and wrong on so many levels)&lt;/h3&gt;  &lt;p&gt;Here is the wrong way to do it and anyone doing this should be taken out and shot.   &lt;br /&gt;string s = &amp;quot;&amp;lt;a href=\&amp;quot;mailto:&amp;quot;;    &lt;br /&gt;s += ConfigurationManager.AppSettings[&amp;quot;IT_EMAIL&amp;quot;];    &lt;br /&gt;s += &amp;quot;\&amp;quot;&amp;gt;&amp;quot;;    &lt;br /&gt;s += ConfigurationManager.AppSettings[&amp;quot;IT_EMAIL&amp;quot;];    &lt;br /&gt;s += &amp;quot;&amp;lt;/a&amp;gt;&amp;quot;;    &lt;br /&gt;litITEmail.Text = s;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-1326902791682006502?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1326902791682006502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1326902791682006502'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/04/short-rant-on-stringbuilder-and-string.html' title='Short Rant on StringBuilder and String'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2014911556437062798</id><published>2009-04-04T12:20:00.000-07:00</published><updated>2010-03-28T12:20:53.711-07:00</updated><title type='text'>Crazy Open Source project!</title><content type='html'>&lt;p&gt;I found out about this project the other day, ReactOS (&lt;a title="http://www.reactos.org/en/index.html " href="http://www.reactos.org/en/index.html "&gt;http://www.reactos.org/en/index.html &lt;/a&gt;) which is an open source version of Windows!&amp;#160; Apparently it will “eventually” replace MS Windows on the Users desktop without Users ever noticing the change. Oh my God!, is this a law suit waiting to happen or not?&lt;/p&gt;  &lt;p&gt;It’s only in Alpha at the moment, but apparently it works well……&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2014911556437062798?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2014911556437062798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2014911556437062798'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/04/crazy-open-source-project.html' title='Crazy Open Source project!'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-7346620140618008922</id><published>2009-04-03T12:24:00.000-07:00</published><updated>2010-03-28T12:25:06.704-07:00</updated><title type='text'>Web Testing Applications</title><content type='html'>&lt;p&gt;One of the great things about the unit testing is that it breaks down tasks into small meaningful chunks; sadly testing web brings up a whole set of new issues.&amp;#160; With web applications the testing is usually based on a script or number of steps which could be spread over any number of different screens.&amp;#160; I’ve used a number of different tools to do this an all have issues and limitations and they all cost heaps of cash.&amp;#160; then I’ve discovered &lt;a href="http://seleniumhq.org/" target="_blank"&gt;Selenium&lt;/a&gt; a free open source tool for doing just that.&lt;/p&gt;  &lt;h3&gt;Installing Selenium on your development machine&lt;/h3&gt;  &lt;p&gt;Selenium is a java based application so you need to install the latest Java Runtime which can be downloaded from the &lt;a href="http://www.java.com/en/download/index.jsp" target="_blank"&gt;Sun website&lt;/a&gt;.&amp;#160; Run the installer taking all the standard defaults and this should place everything needed into your C:\Program Files\Java\ folder.&lt;/p&gt;  &lt;p&gt;Next you need to download a copy of Selenium RC (selenium-remote-control-1.0-beta-2-dist.zip) from the &lt;a href="file://\\dubwsvrt004\Applications$\TestDriven" target="_blank"&gt;application share&lt;/a&gt; or from the &lt;a href="http://seleniumhq.org/" target="_blank"&gt;Selenium website&lt;/a&gt; to your drive. Open this file using Window Explorer or any Zip file reader and extract only the \selenium-remote-control-1.0-beta-2\selenium-server-1.0-beta-2 folder.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-s6Y9GyWI/AAAAAAAAAa4/w25X5alpcg8/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-s6zDRlDI/AAAAAAAAAa8/LYdftHNJa7Q/image_thumb.png?imgmax=800" width="244" height="147" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Extract these file to a folder d:\applications\selenium-server. &lt;/p&gt;  &lt;p&gt;To start the service running you need to go to the command prompt and typing:&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; d:   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cd d:\Applications\selenium-server\    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; java –jar selenium-server.jar&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-s7fABdiI/AAAAAAAAAbA/qFfQXSrA64c/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-s7lxpAwI/AAAAAAAAAbE/yovv2ALxbtk/image_thumb1.png?imgmax=800" width="244" height="125" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You should start to see the output above showing that you now have a server running on port 4444.&lt;/p&gt;  &lt;h3&gt;Installing the Selenium Extension&lt;/h3&gt;  &lt;p&gt;Open the Fire Fox browser and select tools/Add-ons from the menu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-s8KYIhyI/AAAAAAAAAbI/LdwNeg6LDV8/s1600-h/image3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-s8orItyI/AAAAAAAAAbM/wTyaDe9t8Hg/image_thumb1%5B1%5D.png?imgmax=800" width="244" height="232" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select Get Add-Ons from the menu and type Selenium into the search text box and hit return. You should see Selenium IDE appear as the first item in the list. Select this and click the “Add to Firefox” button.&amp;#160; After installation restart Firefox.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-s9DoBp3I/AAAAAAAAAbQ/xL_kX4cJlq0/s1600-h/image6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-s9TkjNmI/AAAAAAAAAbU/OIwtxv_K1NY/image_thumb2.png?imgmax=800" width="244" height="207" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;There should now be a new item added to your Tools menu called Selenium IDE.&amp;#160; &lt;/p&gt;  &lt;h3&gt;Recording a test&lt;/h3&gt;  &lt;p&gt;While on the webpage select Selenium IDE from the Tools menu in Firefox.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-s97BwskI/AAAAAAAAAbY/7_MnkUAcuic/s1600-h/image12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-s-eSy1aI/AAAAAAAAAbc/1rlAECr4Reg/image_thumb4.png?imgmax=800" width="244" height="191" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;A dialogue box should appear and you can notice that the red circle in the top right hand side indicates that you are now in recording mode.&lt;/p&gt;  &lt;p&gt;On the page dome some work, in this case I placed the word “Fred” into the search field and clicked Search.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-s-wBxi2I/AAAAAAAAAbg/WP8iZtSExjQ/s1600-h/image15.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-s_fiRVkI/AAAAAAAAAbk/ycidu_W5IKg/image_thumb5.png?imgmax=800" width="244" height="119" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select the “Page” text (or any text for that matter) on the page and right click.&amp;#160; You should see a submenu stating “Show All Available Commands” and within this “AssertTextPresent Page”.&amp;#160; Assert is the test in this case, you are testing that “Page” text will exist following the search. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-s_3W98LI/AAAAAAAAAbo/oXeY2QjxqVQ/s1600-h/image18.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-tACBj-dI/AAAAAAAAAbs/hF9GvVvY5a4/image_thumb6.png?imgmax=800" width="189" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Going back to your Selenium IDE should present you with 4 commands, one for each of the steps you’ve taken.&amp;#160; Click the red button in to top right of the screen to stop recording your steps and Save by click on File/Save from the menu. &lt;/p&gt;  &lt;h3&gt;Running the test&lt;/h3&gt;  &lt;p&gt;Once you have a saved test, you can run it at any time in the future by opening if from disk using File/Open from the menu. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-tAk3vYWI/AAAAAAAAAbw/0KbJ5h6IVIQ/s1600-h/image21.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-tBGSEiNI/AAAAAAAAAb0/KOMH7DJHAKk/image_thumb7.png?imgmax=800" width="187" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click the green play button on the tool bar to run your test, ensuring that the Base URL is correct.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-tBiy27qI/AAAAAAAAAb4/xETYp8yXLpY/s1600-h/image24.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-tB5ASezI/AAAAAAAAAb8/oxA6K3xwP4A/image_thumb8.png?imgmax=800" width="191" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If all the steps turn green you have successfully run the tests.&lt;/p&gt;  &lt;h3&gt;Adding the Selenium to Integration Server&lt;/h3&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The great thing about Selenium is that you can build each of these tests into the continuous integration server.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-tCbfkPoI/AAAAAAAAAcA/5P5gVvNvEeE/s1600-h/image27.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-tCmdEQdI/AAAAAAAAAcE/DJZqILZ_Mhw/image_thumb9.png?imgmax=800" width="244" height="135" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;From the options menu select Format/C# – Selenium RC.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-tDx0qeCI/AAAAAAAAAcI/jAcFdVn7FDk/s1600-h/image30.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-tEZWOd5I/AAAAAAAAAcM/afGGzWTcRv8/image_thumb10.png?imgmax=800" width="191" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This will present your test in C# code which can be cut/paste into the standard UnitTest infrastructure.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-7346620140618008922?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/7346620140618008922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/7346620140618008922'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/04/web-testing-applications.html' title='Web Testing Applications'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/S6-s6zDRlDI/AAAAAAAAAa8/LYdftHNJa7Q/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-1820742979406630686</id><published>2009-03-30T12:18:00.000-07:00</published><updated>2010-03-28T12:19:12.856-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Adding UnitTests to CruiseControl</title><content type='html'>&lt;p&gt;In this post I’ll describe how to add these tests to the Continuous Integration Server.&amp;#160; The process is very simple really, only a matter of a adding a new task in the Control Control Config Console (CCNETConfig) for that project.&lt;/p&gt;  &lt;h3&gt;Adding your Test to Continuous Integration&lt;/h3&gt;  &lt;p&gt;Assuming you have already added your UnitTest project and added it to the solution. Logon onto your build server and open CCNetConfig.&amp;#160; this is available from the start/all programs menu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-rorrYUrI/AAAAAAAAAaY/1mm4th4Mpfc/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-rpLnowYI/AAAAAAAAAac/5Q2GNzm2ObE/image_thumb.png?imgmax=800" width="244" height="176" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click File/Open from the menu and browse to the servers configuration file (ccnet.config), which should be found in D:\Program Files\CruiseControl.NET\server folder on the local server and click Open.&lt;/p&gt;  &lt;p&gt;Expand the project on which you have added the Unit tests and right click the Tasks node on the tree, in this case it’s MSS.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-rpk3_sPI/AAAAAAAAAag/sNhMF4OHeV0/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-rqP51gSI/AAAAAAAAAak/WoABbEZGpxw/image_thumb1.png?imgmax=800" width="238" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Choose Add Task and NUnitTask from the menu, you should then see the new node added to the tree.&amp;#160; Select this node and add the relevant information to the detail pane on the right.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-rqkzN9jI/AAAAAAAAAao/RKWjHBg40JM/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-rrAlF0NI/AAAAAAAAAas/ruwimSNMwoo/image_thumb2.png?imgmax=800" width="244" height="115" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;(Assemblies) should point to the UnitTest DDL that is built during compilation.&lt;/p&gt;  &lt;p&gt;Output File; should point to the logs folder on the build server&lt;/p&gt;  &lt;p&gt;Path; points to the location of the NUnit Console application&lt;/p&gt;  &lt;p&gt;timeout; Default to 100 seconds for timeout, however increase this for long running test projects. &lt;/p&gt;  &lt;p&gt;Save your changes and you should be fine.&lt;/p&gt;  &lt;h3&gt;Viewing the results&lt;/h3&gt;  &lt;p&gt;Now every time the project builds your tests will be run against all the code.&amp;#160; This will highlight any places where the new code has adversely affected other areas of the solution.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-rruSejoI/AAAAAAAAAaw/bJaCVwc_g34/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-rsK3r3TI/AAAAAAAAAa0/o5hQcpa6uc4/image_thumb3.png?imgmax=800" width="244" height="219" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;From the CCNet control website (http://&amp;lt;server&amp;gt;/CCNet/) you can browse to your project and select “Latest Build” then select the “NUnit Details” link on the right of the screen.&amp;#160; Here you can see that 1 test was completed successfully.&amp;#160; Clicking the NUNIT Timings link will tell you how long it took to run the tests which have be very useful for performance testing.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-1820742979406630686?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1820742979406630686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/1820742979406630686'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/03/adding-unittests-to-cruisecontrol.html' title='Adding UnitTests to CruiseControl'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/S6-rpLnowYI/AAAAAAAAAac/5Q2GNzm2ObE/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-6326884320109732316</id><published>2009-03-28T11:41:00.000-07:00</published><updated>2010-03-28T11:43:33.346-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>Blogging via Windows Live Writer</title><content type='html'>&lt;p&gt;Its important to let everyone know what your doing, so here is an easy way to interact with a blog.  I’d encourage everyone to post once or twice a week anything they’ve learned; be it technical or organisational, important or trivial.  Once it has been entered into the blog others will benefit from that knowledge and we’ll forever have a record.  &lt;/p&gt;  &lt;p&gt;This is software is also ideal for documenting systems and procedures “as-you-go”, as all you need to do is take screen shots and paste them directly into your documentation.&lt;/p&gt;  &lt;p&gt;To start I’ll show you how to download and use Microsoft Windows Live Writer and connect it to a SharePoint Blog.&lt;/p&gt;  &lt;h3&gt;Getting Live Writer&lt;/h3&gt;  &lt;p&gt;The software is freely available from the &lt;a href="http://download.live.com/writer" target="_blank"&gt;Microsoft Website&lt;/a&gt;, simply click the Download button, Click Run and Run again when prompted.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-ipJdeXwI/AAAAAAAAAR4/DkXAGJWAUGA/s1600-h/lr1.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="lr1" border="0" alt="lr1" src="http://lh5.ggpht.com/_r_B45UywYok/S6-ipmqrcLI/AAAAAAAAAR8/um6XNNGKhuo/lr1_thumb.png?imgmax=800" width="244" height="207" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Uncheck everything except “Writer” and click Install.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-iqEr9fCI/AAAAAAAAASA/LWm-00GAyW0/s1600-h/lr2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="lr2" border="0" alt="lr2" src="http://lh6.ggpht.com/_r_B45UywYok/S6-iqrkcehI/AAAAAAAAASE/s9_gzAFZYus/lr2_thumb.png?imgmax=800" width="244" height="207" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You’ll be asked to close Internet Explorer, do this and click Continue.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-irOznfCI/AAAAAAAAASI/nXMaZtnW6HE/s1600-h/lr3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="lr3" border="0" alt="lr3" src="http://lh6.ggpht.com/_r_B45UywYok/S6-irkUQXgI/AAAAAAAAASM/U5hLEk7_hlc/lr3_thumb.png?imgmax=800" width="244" height="207" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You’ll see the Progress bar during the installation.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-isBmlhbI/AAAAAAAAASQ/VZ4topeF4p0/s1600-h/lr4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="lr4" border="0" alt="lr4" src="http://lh4.ggpht.com/_r_B45UywYok/S6-iscHHElI/AAAAAAAAASU/Go5Z-Q9gAus/lr4_thumb.png?imgmax=800" width="244" height="207" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Deselect everything from the additional installation window as you don’t need it and click Continue.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-is66unPI/AAAAAAAAASY/s9LqANk6xLE/s1600-h/lr5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="lr5" border="0" alt="lr5" src="http://lh3.ggpht.com/_r_B45UywYok/S6-itTsy83I/AAAAAAAAASc/_jOW0aPxlm8/lr5_thumb.png?imgmax=800" width="244" height="207" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Finally click close and you should be ready to start using the software.&lt;/p&gt;  &lt;h3&gt;Starting Live Writer and connecting to the IT Blog.&lt;/h3&gt;  &lt;p&gt;Once installed you should get a new item in your Start/Programs/Windows Live menu called Windows LiveWriter.  It should open first time only asking you to connect to a default Blogging site.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-it9QpweI/AAAAAAAAASg/sg_ElQuNZvQ/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-iub1O7yI/AAAAAAAAASk/wMHN3qO90PY/image_thumb.png?imgmax=800" width="244" height="235" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click Add..&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-iuiBChII/AAAAAAAAASo/EX32tRYMiaM/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-ivIcT6SI/AAAAAAAAASs/dm5xUoH044s/image_thumb11.png?imgmax=800" width="244" height="208" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select SharePoint Blog and click Next.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-ivoQOxhI/AAAAAAAAASw/kg6V_ccCJyM/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-iv9LLR3I/AAAAAAAAAS0/jb3pZ3iyAts/image_thumb2.png?imgmax=800" width="244" height="208" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In the Blog URL you need to type the following: &lt;a title="http://eiportal/sites/it/blog/default.aspx" href="http://%26lt/;server&amp;gt;/sites/it/blog/default.aspx,%20then"&gt;/sites/it/blog/default.aspx, then"&amp;gt;http://&amp;lt;server&amp;gt;/sites/it/blog/default.aspx, then&lt;/a&gt; click Next.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-iwUFOGcI/AAAAAAAAAS4/1cCqBX-DNf4/s1600-h/image14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-iwo88QMI/AAAAAAAAAS8/ewE85gp62sc/image_thumb4.png?imgmax=800" width="244" height="208" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You should see a progress window as Live Writer searches for the Blog details.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-ixM6QfaI/AAAAAAAAATA/2W307f_nZn8/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-ixinfiCI/AAAAAAAAATE/Mg37Vk5DReY/image_thumb3.png?imgmax=800" width="244" height="208" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If successful you will be asked for a Blog Name, I’d recommend choosing the same name as the blog, as you can add additional blogs to the application if needed.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-ix0EFEjI/AAAAAAAAATI/sj8IadETj-8/s1600-h/image3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-iybM07zI/AAAAAAAAATM/mBiN6fzxyk8/image_thumb1.png?imgmax=800" width="244" height="226" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You should now be able to access the Blog each time the application starts.  If this is your only blog, it will open be default, however if you want to use multiple blogs be sure to check the upper right of the screen which should say “Blog”.&lt;/p&gt;  &lt;h3&gt;Publishing a post&lt;/h3&gt;  &lt;p&gt;Live writer is much like Word simply type in the work space and cut/paste images and screen shots.  When you are finished click the Publish button in the upper left hand corner of the tool bar.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-iy4gecBI/AAAAAAAAATQ/6wGfbm68-Rc/s1600-h/image6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-izWdqJeI/AAAAAAAAATU/JbxDLTlAqu0/image_thumb21.png?imgmax=800" width="244" height="113" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You should see the progress bar and finally a new Browser window will open and you can see your blog entry.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-6326884320109732316?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6326884320109732316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6326884320109732316'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2010/03/blogging-via-windows-live-writer.html' title='Blogging via Windows Live Writer'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh5.ggpht.com/_r_B45UywYok/S6-ipmqrcLI/AAAAAAAAAR8/um6XNNGKhuo/s72-c/lr1_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-8613151151374571290</id><published>2009-03-25T12:10:00.000-07:00</published><updated>2010-03-28T12:10:11.752-07:00</updated><title type='text'>ASP.NET Mobile Browser</title><content type='html'>&lt;p&gt;I’ve been investigating doing a port of my iPhone application to other platforms and discovered an interesting tool called &lt;a href="http://mdbf.codeplex.com/" target="_blank"&gt;Mobile Browser Definition File&lt;/a&gt;.&amp;#160; The file contains capability definitions for about 70% of the main mobile devices and browsers in use today.&amp;#160; Your ASP.NET project can use the .browser file, along with the information in the HTTP request header, to determine what type of device/browser has made the request and what the capabilities of that device are.&lt;/p&gt;  &lt;p&gt;Check it out, it’s very useful if anyone wants to do work on mobile devices.&amp;#160; Did you know for example that many of the new Nokia phones don’t support the PNG graphic format!?&amp;#160; &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-8613151151374571290?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/8613151151374571290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/8613151151374571290'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/03/aspnet-mobile-browser_25.html' title='ASP.NET Mobile Browser'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-8522635588524334905</id><published>2009-03-23T12:08:00.000-07:00</published><updated>2010-03-28T12:08:59.841-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Enable ASP debugging in an ASP.NET 3.5 Site</title><content type='html'>&lt;p&gt;Today I got this error on an ASP running under Visual Studio 2008.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-pQYTZXOI/AAAAAAAAAaA/1YTuCWVwFiw/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-pQ65wNoI/AAAAAAAAAaE/RIJ0s1lWn_s/image_thumb.png?imgmax=800" width="244" height="167" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The error text was as follows:&lt;/p&gt;  &lt;p&gt;The type of page you have requested is not served because it has been explicitly forbidden.&amp;#160; The extension '.asp' may be incorrect.&amp;#160;&amp;#160; Please review the URL below and make sure that it is spelled correctly. &lt;/p&gt;  &lt;p&gt;It turns out that ASP is not supported under Visual Studio 2008 unless you make 2 additions to the local Web.Config file.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;lt;compilation debug=&amp;quot;false&amp;quot;&amp;gt;   &lt;br /&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;buildProviders&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;add extension=&amp;quot;.asp&amp;quot; type=&amp;quot;System.Web.Compilation.PageBuildProvider&amp;quot; /&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/buildProviders&amp;gt;&lt;/strong&gt;&lt;/p&gt; &amp;lt;/compilation&amp;gt;  &lt;br /&gt;  &lt;p&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;lt;httpHandlers&amp;gt;   &lt;br /&gt;&lt;strong&gt;&amp;lt;add path=&amp;quot;*.asp&amp;quot; verb=&amp;quot;*&amp;quot; type=&amp;quot;System.Web.UI.PageHandlerFactory&amp;quot; validate=&amp;quot;true&amp;quot; /&amp;gt;     &lt;br /&gt;&lt;/strong&gt;&amp;lt;/httpHandlers&amp;gt; &lt;/p&gt;  &lt;p&gt;This will enable ASP to work in the debug browser however if you have relative paths it won’t work as you’re running only one project under a specific port number. &lt;/p&gt;  &lt;p&gt;i.e You will get this type of error.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-pRbuRCSI/AAAAAAAAAaI/mlwYhrQEo-c/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-pRpzkzDI/AAAAAAAAAaM/1tkBuuNuxEo/image_thumb2.png?imgmax=800" width="244" height="218" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Alternatively you can just set the server in the project properties to run under local IIS, which is just as good. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-pSDjcJsI/AAAAAAAAAaQ/19inaFrpqI4/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-pSuLde2I/AAAAAAAAAaU/Yn5ACjkiCw8/image_thumb1.png?imgmax=800" width="244" height="138" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-8522635588524334905?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/8522635588524334905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/8522635588524334905'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/03/enable-asp-debugging-in-aspnet-35-site.html' title='Enable ASP debugging in an ASP.NET 3.5 Site'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh3.ggpht.com/_r_B45UywYok/S6-pQ65wNoI/AAAAAAAAAaE/RIJ0s1lWn_s/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-9213858394406112393</id><published>2009-03-21T09:38:00.000-07:00</published><updated>2009-03-21T09:45:12.652-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>The Developer Disk Image could not be mounted</title><content type='html'>I got the following error when trying to deploy the latest version of my iPhone application to my iPod Touch.&lt;br /&gt;&lt;br /&gt;The Developer Disk Image could not be mounted.&lt;br /&gt;Xcode could not find an appropriate Developer Disk Image to mount on XXXXX iPod. Please contact Apple for the 2.2.1 (5H11) device support package.&lt;br /&gt;&lt;br /&gt;Going onto the &lt;a href="http://developer.apple.com/iphone/index.action"&gt;Apple Developers&lt;/a&gt; site and getting the latest copy of the SDK fixed the issue.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-9213858394406112393?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/9213858394406112393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/9213858394406112393'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/03/developer-disk-image-could-not-be.html' title='The Developer Disk Image could not be mounted'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2148524079642980197</id><published>2009-03-20T13:34:00.001-07:00</published><updated>2009-03-20T13:34:18.486-07:00</updated><title type='text'>Working with Azure</title><content type='html'>&lt;p&gt;I’m back in action after a long time away from my iPhone application development.&amp;#160; It took a very interesting weekend conference called BizCamp to get me back into doing some development again.&amp;#160; Thanks should also go to Stephen and Joel for getting me off the sofa, watching BSG until 1am at the weekend.&lt;/p&gt;  &lt;p&gt;The basic idea here is to add some bug tracking functionality to my iPhone applications site.&amp;#160; This request came from one of my beta testers who commented that this type of functionality gives a better feeling of community.&lt;/p&gt;  &lt;p&gt;I’m assuming that the developer reading this has all the various software downloads needed to run Azure.&amp;#160; I’m also assuming that you’ve gone through the pain and suffering required to obtain your invitation code to the CTP.&lt;/p&gt;  &lt;h3&gt;The Basic Design&lt;/h3&gt;  &lt;p&gt;Due to the limited data types available in Azure I’m going to keep the implementation very simple, just one table to hold all the data.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/ScP8vAomPVI/AAAAAAAAAPI/UbOBax9XLO8/s1600-h/Picture22.png"&gt;&lt;img title="Picture 2" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="164" alt="Picture 2" src="http://lh6.ggpht.com/_r_B45UywYok/ScP8w50LALI/AAAAAAAAAPM/_2etlnk-P4Q/Picture2_thumb.png?imgmax=800" width="209" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Each field is defined as a string however during implementation I’ll add 3 extra fields to support Azure.&amp;#160; ID which is a simple INT used as a Primary Key, PartitionKey a GUID used by Azure storage and RowKey which will match the Primary Key.&lt;/p&gt;  &lt;p&gt;The User will simply fill in the error description via the website or within the iPhone application.&amp;#160; These records will be given a status of “Open”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/ScP8xMA41uI/AAAAAAAAAPQ/Xgu644CqN6A/s1600-h/image%5B2%5D.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/ScP8xs01q6I/AAAAAAAAAPU/BOdTTcrb1Yk/image_thumb.png?imgmax=800" width="243" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Later the records are reviewed within the Administration section of the website where each bug is given a status of “In Progress”, “On Hold” or “Closed”; however I’ll leave that functionality outside this posting as it’s basically using the same techniques.&lt;/p&gt;  &lt;h2&gt;Class Development&lt;/h2&gt;  &lt;p&gt;First we create 3 main classes; the first being the query definition class which encapsulates a simple list.&lt;/p&gt;  &lt;h3&gt;The context class&lt;/h3&gt;  &lt;p&gt;public class CloudContext : TableStorageDataServiceContext    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; internal CloudContext(StorageAccountInfo accountInfo)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : base(accountInfo)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; }&lt;/p&gt;  &lt;p&gt;&amp;#160; // table name    &lt;br /&gt;internal const string BugsTableName = &amp;quot;BugTable&amp;quot;; &lt;/p&gt;  &lt;p&gt;// Query Definition    &lt;br /&gt;public IQueryable&amp;lt;UserDataModel&amp;gt; BugTable     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { get     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { return this.CreateQuery&amp;lt;BugDataModel&amp;gt;(BugTableName); } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;}&lt;/p&gt;  &lt;p&gt;The TableStorageDataServiceContext class handles the authentication process into the Table Storage service.&lt;/p&gt;  &lt;h3&gt;The Data model&lt;/h3&gt;  &lt;p&gt;public class BugDataModel : TableStorageEntity    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public BugDataModel(string partitionKey, string rowKey)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : base(partitionKey, rowKey)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public BugDataModel()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : base()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; PartitionKey = Guid.NewGuid().ToString();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RowKey = String.Empty;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public int ID    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public string Name    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public string Email    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public string ErrorDescription    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public string ErrorResolution    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public string Status    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Which is a definition of the actual storage structure.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h3&gt;The Data Source&lt;/h3&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public class BugDataSource    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private CloudContext _ServiceContext = null; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public BugDataSource()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Get the settings from the Service Configuration file     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; StorageAccountInfo account =     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; StorageAccountInfo.GetDefaultTableStorageAccountFromConfiguration(); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Create the service context we'll query against    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _ServiceContext = new CloudContext(account);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _ServiceContext.RetryPolicy = RetryPolicies.RetryN(3, TimeSpan.FromSeconds(1));     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public IEnumerable&amp;lt;BugDataModel&amp;gt; Select()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var results = from b in _ServiceContext.BugTable     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; select b; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TableStorageDataServiceQuery&amp;lt;BugDataModel&amp;gt; query =    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; new TableStorageDataServiceQuery&amp;lt;BugDataModel&amp;gt;(results as DataServiceQuery&amp;lt;BugDataModel&amp;gt;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IEnumerable&amp;lt;BugDataModel&amp;gt; queryResults = query.ExecuteAllWithRetries();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return queryResults;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public IEnumerable&amp;lt;BugDataModel&amp;gt; SelectByID(int id)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var results = from c in _ServiceContext.BugTable     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; where c.ID == id     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; select c;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TableStorageDataServiceQuery&amp;lt;BugDataModel&amp;gt; query =     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; new TableStorageDataServiceQuery&amp;lt;BugDataModel&amp;gt;(results as DataServiceQuery&amp;lt;BugDataModel&amp;gt;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IEnumerable&amp;lt;BugDataModel&amp;gt; queryResults = query.ExecuteAllWithRetries();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return queryResults;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Delete(BugDataModel itemToDelete)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IEnumerable&amp;lt;BugDataModel&amp;gt; bugs = this.SelectByID(itemToDelete.ID);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (BugDataModel bug in bugs)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _ServiceContext.DeleteObject(bug);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _ServiceContext.SaveChanges();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Update(BugDataModel itemToUpdate)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IEnumerable&amp;lt;BugDataModel&amp;gt; bugs = this.SelectByID(itemToUpdate.ID);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (BugDataModel bug in bugs)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bug.Name = itemToUpdate.Name;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bug.Email = itemToUpdate.Email;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bug.ErrorDescription = itemToUpdate.ErrorDescription;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bug.ErrorResolution = itemToUpdate.ErrorResolution;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bug.Status = itemToUpdate.Status; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _ServiceContext.UpdateObject(bug);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _ServiceContext.SaveChanges();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Insert(BugDataModel newItem)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // we must overwrite the supplied ID with the MAX as Azure does not yet support Identity columns     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // with simple storeage tables. &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int Id = this.GetNextID();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; newItem.ID = Id;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; newItem.RowKey = Id.ToString();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _ServiceContext.AddObject(CloudContext.BugTableName, newItem);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _ServiceContext.SaveChanges();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #region&amp;#160; -- Private methods --    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Simple function to find the max results from a recordset of IDs and add one.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;the next id number&amp;lt;/returns&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private int GetNextID()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int maxID=0;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IEnumerable&amp;lt;BugDataModel&amp;gt; categories = this.Select();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (BugDataModel Entry in categories)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (Entry.ID &amp;gt; maxID) maxID = Entry.ID;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; maxID++;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return maxID;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #endregion &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The DataSource class is the real work horse of the application.&amp;#160; It’s the controller for getting information in and out of the storage structure.&lt;/p&gt;  &lt;p&gt;You’ll notice that I’ve added a GetNextID private method which I’m not really happy about, but it’s the only way I could see to duplicate the functionality needed to mimic a normal database structure.&lt;/p&gt;  &lt;h2&gt;Web Interface Development&lt;/h2&gt;  &lt;p&gt;Next we create the web interface code.&amp;#160; In my project I separated the web code into another project and added a reference to the Model classes, but it’s not essential.&lt;/p&gt;  &lt;p&gt;Create a new ASPX page to allow a Bug to be registered (Inserted) by the Users.&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;h2&amp;gt;Report your problems here&amp;lt;/h2&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:FormView id=&amp;quot;frmAdd&amp;quot; DataSourceId=&amp;quot;bugData&amp;quot; DefaultMode=&amp;quot;Insert&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Runat=&amp;quot;server&amp;quot; OnItemInserted=&amp;quot;frmAdd_ItemInserted&amp;quot; &amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;InsertItemTemplate&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;table&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&amp;lt;asp:Label id=&amp;quot;nameLabel&amp;quot; Text=&amp;quot;*Name:&amp;quot; AssociatedControlID=&amp;quot;nameBox&amp;quot; Runat=&amp;quot;server&amp;quot; /&amp;gt;&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&amp;lt;asp:TextBox id=&amp;quot;nameBox&amp;quot; Text='&amp;lt;%# Bind(&amp;quot;Name&amp;quot;) %&amp;gt;' Runat=&amp;quot;server&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:RequiredFieldValidator ID=&amp;quot;reqName&amp;quot; ControlToValidate=&amp;quot;nameBox&amp;quot; runat=&amp;quot;server&amp;quot; ErrorMessage=&amp;quot;Required&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&amp;lt;asp:Label id=&amp;quot;emailLabel&amp;quot; Text=&amp;quot;Email:&amp;quot; AssociatedControlID=&amp;quot;emailBox&amp;quot; Runat=&amp;quot;server&amp;quot; /&amp;gt;&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&amp;lt;asp:TextBox id=&amp;quot;emailBox&amp;quot; Text='&amp;lt;%# Bind(&amp;quot;Email&amp;quot;) %&amp;gt;' Runat=&amp;quot;server&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:RegularExpressionValidator     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ID=&amp;quot;RegularExpressionValidator1&amp;quot; runat=&amp;quot;server&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ControlToValidate=&amp;quot;emailBox&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ErrorMessage=&amp;quot;email format&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ValidationExpression=&amp;quot;\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&amp;lt;asp:Label id=&amp;quot;errorDescriptionLabel&amp;quot; Text=&amp;quot;*Description:&amp;quot; AssociatedControlID=&amp;quot;errorDescriptionBox&amp;quot; Runat=&amp;quot;server&amp;quot; /&amp;gt;&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&amp;lt;asp:TextBox id=&amp;quot;errorDescriptionBox&amp;quot; Rows=&amp;quot;10&amp;quot; TextMode=&amp;quot;MultiLine&amp;quot; Text='&amp;lt;%# Bind(&amp;quot;ErrorDescription&amp;quot;) %&amp;gt;' Runat=&amp;quot;server&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:RequiredFieldValidator ID=&amp;quot;reqRescription&amp;quot; ControlToValidate=&amp;quot;errorDescriptionBox&amp;quot; runat=&amp;quot;server&amp;quot; ErrorMessage=&amp;quot;Required&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:TextBox id=&amp;quot;errorResolution&amp;quot; Visible=&amp;quot;false&amp;quot; Text='&amp;lt;%# Bind(&amp;quot;ErrorResolution&amp;quot;) %&amp;gt;' Runat=&amp;quot;server&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&amp;lt;asp:Label id=&amp;quot;statusLabel&amp;quot; Text=&amp;quot;Status:&amp;quot; AssociatedControlID=&amp;quot;statusBox&amp;quot; Runat=&amp;quot;server&amp;quot; /&amp;gt;&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&amp;lt;asp:TextBox id=&amp;quot;statusBox&amp;quot; Value=&amp;quot;Open&amp;quot; Text='&amp;lt;%# Bind(&amp;quot;Status&amp;quot;) %&amp;gt;' Runat=&amp;quot;server&amp;quot; /&amp;gt;&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td colspan=&amp;quot;2&amp;quot;&amp;gt;&amp;lt;label&amp;gt;* indicates a manditory field.&amp;lt;/label&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr align=&amp;quot;center&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td colspan=&amp;quot;2&amp;quot;&amp;gt;&amp;lt;asp:Button id=&amp;quot;insertButton&amp;quot; Text=&amp;quot;Report&amp;quot; CommandName=&amp;quot;Insert&amp;quot; Runat=&amp;quot;server&amp;quot;/&amp;gt;&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/table&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/InsertItemTemplate&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/asp:FormView&amp;gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;%-- Confirmation message --%&amp;gt;      &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:Panel id=&amp;quot;frmMessage&amp;quot; Visible=&amp;quot;false&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Your error has been received and will be actioned as soon as possible.&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;p&amp;gt;&amp;lt;a href=&amp;quot;Default.aspx&amp;quot;&amp;gt;Return to Home&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/asp:Panel&amp;gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;%-- Data Sources --%&amp;gt;      &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;asp:ObjectDataSource runat=&amp;quot;server&amp;quot; ID=&amp;quot;bugData&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TypeName=&amp;quot;BusinessObjects.BugDataSource&amp;quot; InsertMethod=&amp;quot;Insert&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DataObjectTypeName=&amp;quot;BusinessObjects.BugDataModel&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SelectMethod=&amp;quot;Select&amp;quot;&amp;gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/asp:ObjectDataSource&amp;gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;As you can see I’ve created 3 main functional areas.&amp;#160; An ASP.FormView which has a field for each record to be inserted.&amp;#160; Each of these is linked to the asp:ObjectDataSource called “bugData”.&amp;#160; An finally an ASP:Panel which is displayed when the “insertButton” is pressed.&lt;/p&gt;  &lt;p&gt;protected void frmAdd_ItemInserted(object sender, FormViewInsertedEventArgs e)    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; frmAdd.Visible = false;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; frmMessage.Visible = true;     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Above it the only code in the code behind to implement the OnPressed event.&lt;/p&gt;  &lt;p&gt;Build everything and you should be almost ready to run a test.&lt;/p&gt;  &lt;h2&gt;Generating the local storage and running locally&lt;/h2&gt;  &lt;p&gt;Next we need to run the program locally to ensure it’s working.&lt;/p&gt;  &lt;p&gt;First off we need to generate the database structure into the local development storage.&amp;#160; At this point I’m assuming that you’ve got it up an running as it worked ‘”all most” out of the box for me.&amp;#160; I did have to tweek the configurations as I was running under a SQL2008 database under a named instance.&lt;/p&gt;  &lt;p&gt;I created a simple generate batch file so I could run it a few times.&lt;/p&gt;  &lt;p&gt;echo -- Generate the Azure Storeage database    &lt;br /&gt;set EXE_PATH=C:\Program Files\Windows Azure SDK\v1.0\bin\     &lt;br /&gt;set SOURCE_PATH=C:\Development\AzureProj\Interfaces\ &lt;/p&gt;  &lt;p&gt;&amp;quot;%EXE_PATH%DevtableGen.exe&amp;quot; /forceCreate &amp;quot;/server:(local)&amp;quot; &amp;quot;/database:Service_Azure&amp;quot; &amp;quot;%SOURCE_PATH%bin\BusinessObjects.dll;%SOURCE_PATH%bin\ServerAzure.dll&amp;quot;&lt;/p&gt;  &lt;p&gt;As you can see the DevtableGen application uses reflection to read the contents your application and will create the tables in the local storage account.&lt;/p&gt;  &lt;p&gt;As a side note you can check the DevelopmentStorage.exe.config file and hunt out the code below to find the location of your local database.&lt;/p&gt;  &lt;p&gt;&amp;lt;connectionStrings&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;add name=&amp;quot;DevelopmentStorageDbConnectionString&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; connectionString=&amp;quot;Data Source=(local);Initial Catalog=DevelopmentStorageDb;Integrated Security=True&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; providerName=&amp;quot;System.Data.SqlClient&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;lt;/connectionStrings&amp;gt;&lt;/p&gt;  &lt;p&gt;You can check that everything worked by opening SQL Management Studio.&lt;/p&gt;  &lt;p&gt;When you run the application now you should be able to see everything in action.&amp;#160; I’ll admit I’ve omitted the basic instructions for creating the various projects, but Azure is not for the faint hearted so it’s fair enough to say if you need that information you really won’t be getting the most out of this posting. &lt;/p&gt;  &lt;h2&gt;Azure Deployment&lt;/h2&gt;  &lt;p&gt;Assuming you’ve got your CTP invitation you should create a Storage Project and a hosted project. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/ScP8xwRTXAI/AAAAAAAAAPY/Xxw_aq01t9I/s1600-h/image%5B11%5D.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="138" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/ScP8ypoPWPI/AAAAAAAAAPc/uIBqQSnrIl0/image_thumb%5B3%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;When you select each you’ll get the information you need to place in the configuration files.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/ScP8zBzziQI/AAAAAAAAAPg/aFjUZscckaw/s1600-h/image%5B14%5D.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="129" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/ScP8zTd16WI/AAAAAAAAAPk/SYa7qACbpvA/image_thumb%5B4%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;The Storage project will provide you with the Access keys and http address for accessing the hosted data.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/ScP8z3tX7YI/AAAAAAAAAPo/K6R_FwQQjZU/s1600-h/image%5B17%5D.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/ScP80m3JLoI/AAAAAAAAAPs/jD1XwQ7eN2E/image_thumb%5B5%5D.png?imgmax=800" width="201" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Within the Hosted application you’ll get the Application ID.&lt;/p&gt;  &lt;p&gt;Now it’s time up update your Azure project, which is automatically created when you create the solution.&amp;#160; Here you’ll find 2 configuration files; ServiceConfiguration.cscfg and ServiceDefinition.csdef.&lt;/p&gt;  &lt;h3&gt;ServiceConfiguration.cscfg&lt;/h3&gt;  &lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;    &lt;br /&gt;&amp;lt;ServiceConfiguration serviceName=&amp;quot;Service&amp;quot; xmlns=&amp;quot;&lt;a href="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration&amp;quot;"&gt;http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration&amp;quot;&lt;/a&gt;&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;Role name=&amp;quot;Web&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Instances count=&amp;quot;1&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ConfigurationSettings&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Setting name=&amp;quot;AccountName&amp;quot; value=&amp;quot;xxxxxxxxxxxxx&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Setting name=&amp;quot;AccountSharedKey&amp;quot;&amp;#160;&amp;#160;&amp;#160; value=&amp;quot;xxxxxxxxxxxx&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Setting name=&amp;quot;TableStorageEndpoint&amp;quot; value=&amp;quot;&lt;a href="http://127.0.0.1:10002/&amp;quot;/"&gt;http://127.0.0.1:10002/&amp;quot;/&lt;/a&gt;&amp;gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/ConfigurationSettings&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;/Role&amp;gt;     &lt;br /&gt;&amp;lt;/ServiceConfiguration&amp;gt;&lt;/p&gt;  &lt;p&gt;This file holds the configuration setting for accessing the service.&amp;#160; Above is only the local setting, once you deploy you’ll need to update these values to those generated in Azure.&lt;/p&gt;  &lt;h3&gt;ServiceDefinition.cscfg&lt;/h3&gt;  &lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;    &lt;br /&gt;&amp;lt;ServiceDefinition name=&amp;quot;xxxxxxxxxxx&amp;quot; xmlns=&amp;quot;&lt;a href="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition&amp;quot;"&gt;http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition&amp;quot;&lt;/a&gt;&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;WebRole name=&amp;quot;Web&amp;quot;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;InputEndpoints&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;InputEndpoint name=&amp;quot;HttpIn&amp;quot; protocol=&amp;quot;http&amp;quot; port=&amp;quot;80&amp;quot; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/InputEndpoints&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ConfigurationSettings&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Setting name=&amp;quot;AccountName&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Setting name=&amp;quot;AccountSharedKey&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Setting name=&amp;quot;TableStorageEndpoint&amp;quot;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/ConfigurationSettings&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;/WebRole&amp;gt;     &lt;br /&gt;&amp;lt;/ServiceDefinition&amp;gt;&lt;/p&gt;  &lt;h3&gt;Project properties&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/ScP81He9_qI/AAAAAAAAAPw/ukGgQ-eMKuQ/s1600-h/image%5B8%5D.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="138" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/ScP9Z5lpS9I/AAAAAAAAAP4/gyBA--FpcVU/image_thumb%5B2%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Right clicking the Azure project and selecting the Portal tab and enter the Application ID which is available on the Azure site.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;At this stage you’re ready to run everything, however I’m not going to describe that as you should be able to figure it out from here.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2148524079642980197?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devrichardagreene.blogspot.com/feeds/2148524079642980197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7889773289404691484&amp;postID=2148524079642980197' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2148524079642980197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2148524079642980197'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/03/working-with-azure.html' title='Working with Azure'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh6.ggpht.com/_r_B45UywYok/ScP8w50LALI/AAAAAAAAAPM/_2etlnk-P4Q/s72-c/Picture2_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-2023500699012947675</id><published>2009-03-11T12:05:00.000-07:00</published><updated>2010-03-28T12:07:09.251-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>Creating your SharePoint Development Environment</title><content type='html'>&lt;p&gt;The SharePoint Development Environment is an all in one platform for the correct development and deployment of features.&amp;#160; It is designed to run on a development machine locally, package up all necessary code and deploy customisations to the Test and Production servers.&lt;/p&gt;  &lt;h3&gt;Setup of the Virtual Machine&lt;/h3&gt;  &lt;p&gt;Get a pre-built copy of the latest VM image from your server.&amp;#160; Copy both the VHD and VMC files to your D:\VMs directory.&amp;#160; &lt;strong&gt;Note&lt;/strong&gt;: My&amp;#160; build contained Windows 2003 server with SQLServer 2000 and Visual Studio 2008, SharePoint MOSS Dev Tools and some site content and was about 18Gb in size therefore you should have at least 20Gb free.&lt;/p&gt;  &lt;p&gt;Install the Virtual PC software onto your host machine by running setup.exe on the CD or Download from Microsoft.&amp;#160; When the software has been installed double click the Microsoft Virtual PC icon on your desktop.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-oh1s4MsI/AAAAAAAAAWo/5BbqEsV0jbM/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-oiK0eFHI/AAAAAAAAAWs/9pP3FeSsprI/image_thumb.png?imgmax=800" width="244" height="174" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click “New” then “Next”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-oixPRgsI/AAAAAAAAAWw/Eh6GGjZif24/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-ojYFwtlI/AAAAAAAAAW0/GTJ4eV8nVDc/image_thumb1.png?imgmax=800" width="244" height="192" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select the “Add existing virtual machine” check box and click “Next”.&amp;#160; click “Browse” and select the location where the “SharePoint MOSS Dev Tools and Content.vmc” ws copied to on your local machine.&amp;#160; Then click “Next”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-ojvUIKKI/AAAAAAAAAW4/1HA6h_086rg/s1600-h/image8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-okBVWLZI/AAAAAAAAAW8/pEYD6nvRvs4/image_thumb2.png?imgmax=800" width="244" height="192" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Ensure that “When I click Finish, open Settings” is checked and click “Finish”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-okqtGVlI/AAAAAAAAAXA/gh9tQyXv6yI/s1600-h/image14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-okz2R0-I/AAAAAAAAAXE/gkuUoLVpCHc/image_thumb4.png?imgmax=800" width="244" height="173" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select Memory from the left had side and use the slider to set the amount allocated to the VM.&amp;#160; If you have 2Gb of RAM on the host set it to 1GB, if you have 4Gb of RAM set it to 2Gb, etc. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-oldUbbqI/AAAAAAAAAXI/WPhHsV5uJc4/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-olsOuClI/AAAAAAAAAXM/TrV4wSb4vMQ/image_thumb3.png?imgmax=800" width="244" height="173" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select “Hard Disk 1” from the left had side and Click “Browse” on the right.&amp;#160; Select the “SharePoint MOSS Dev Tools and Content.vhd” file which you have stored on your local pc.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-omY4R3bI/AAAAAAAAAXQ/KN_DArIS_9c/s1600-h/image17.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-om-aR3EI/AAAAAAAAAXU/B4GcpnM99ig/image_thumb5.png?imgmax=800" width="244" height="173" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select Shared folders” from the left had side and ensure that your Host PC’s D drive is mapped to the VM’s D drive.&amp;#160; We do this to ensure that SourceSafe and Visual Studio will operate correctly on the VM server.&amp;#160; Finally click OK and you should see that the Virtual machine has been added to your dialogue.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-onOcizZI/AAAAAAAAAXY/xhhGAG8oZQ8/s1600-h/image20.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-onlFchoI/AAAAAAAAAXc/XtZvdUXFxUE/image_thumb6.png?imgmax=800" width="244" height="174" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select the SharePoint MOSS VM and click “Start”.&amp;#160; &lt;/p&gt;  &lt;h3&gt;Starting up and Configuring your of the Virtual Machine&lt;/h3&gt;  &lt;p&gt;Each VM needs to be configured for each developer to ensure that there is no IP Addressing or deployment issues that could conflict with correct operation.&amp;#160; Once the VM starts on your PC you should disable the network connection.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-on51GUaI/AAAAAAAAAXg/u0YHnkw6ZvA/s1600-h/image26.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-ooFEkhhI/AAAAAAAAAXk/RF4y1lM3AI8/image_thumb8.png?imgmax=800" width="136" height="68" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Right click the network icon (last on the right, next to the folder) and select Network Settings. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-ooiT60PI/AAAAAAAAAXo/YwuTKp0gD6M/s1600-h/image29.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-oo5I6W0I/AAAAAAAAAXs/O87R3BsrNbE/image_thumb9.png?imgmax=800" width="244" height="173" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select “Not Connected” from the drop down next to Adapter 1 and click “OK”.&lt;/p&gt;  &lt;p&gt;Login to the VM using the local Administration account by holding down &amp;lt;Alt Gr&amp;gt; and clicking “Delete”, this is equivalent to sending &amp;lt;CTRL&amp;gt;&amp;lt;ALT&amp;gt;&amp;lt;DEL&amp;gt; on your VM.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-opJ8DwRI/AAAAAAAAAXw/vmn23pMG9MA/s1600-h/image32.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-oplN2H4I/AAAAAAAAAX0/kPgo_Gz6rXc/image_thumb10.png?imgmax=800" width="244" height="162" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;DUBWSDEV010 is the name of the original template used to create the VM, we will be changing this to match your VM name.&amp;#160; The Password can be obtained from your SharePoint Administrator.&lt;/p&gt;  &lt;p&gt;When loaded you should be presented with a standard desktop.&amp;#160; Follow the instructions below to rename the MOSS installation.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-oqAQqH3I/AAAAAAAAAX4/SQoe8F4c2tU/s1600-h/image35.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-oqW3JEhI/AAAAAAAAAX8/-qUI3NJqe08/image_thumb11.png?imgmax=800" width="244" height="236" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;1) Go to the Sharepoint Central Administration &amp;gt; Operations &amp;gt; Services on Server&amp;#160; and stop all running services e.g. &amp;quot;Windows SharePoint Services Search&amp;quot;, “Windows SharePoint Services Search “, etc.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-oqyu6yMI/AAAAAAAAAYA/oJFcQkS0uHI/s1600-h/image40.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-orWqYxDI/AAAAAAAAAYE/12IR3JQaSME/image_thumb14.png?imgmax=800" width="385" height="101" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click Stop on anything started.&lt;/p&gt;  &lt;p&gt;2) Double click the Newsid.exe icon.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-or33k4qI/AAAAAAAAAYI/gv0srPebDhk/s1600-h/image43.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-osMVQP5I/AAAAAAAAAYM/et8fDmNq-s8/image_thumb15.png?imgmax=800" width="244" height="165" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click Agree and Click Next.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-osgymAII/AAAAAAAAAYQ/cnvqwCBVjt0/s1600-h/image46.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-os_eBUSI/AAAAAAAAAYU/gXil-wp5R10/image_thumb16.png?imgmax=800" width="244" height="161" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select Random SID and Click Next&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-otT-MC1I/AAAAAAAAAYY/MrYvKxzNK0E/s1600-h/image49.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-ot-XdiRI/AAAAAAAAAYc/QtNNMkEBNKA/image_thumb17.png?imgmax=800" width="244" height="165" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click “Rename the computer to:” and the new name of the development VM.&amp;#160; This should be in the format DUBWSDEV### where ### is a number from 010 to 019.&amp;#160; See the SharePoint Administrator for your assigned computer name and IP Address.&amp;#160; Click “Next”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-ouE1N1jI/AAAAAAAAAYg/6O26PFzRmb4/s1600-h/image52.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-ouqoDw1I/AAAAAAAAAYk/IsvcWjhkFCo/image_thumb18.png?imgmax=800" width="244" height="163" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Be sure to uncheck the Automatically reboot when SID is applied box and click “Next”.&lt;/p&gt;  &lt;p&gt;After some time processing the new SID should have been applied to your server.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-ou5FMVdI/AAAAAAAAAYo/Skdlumsgppo/s1600-h/image55.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-ovkVj6fI/AAAAAAAAAYs/pbZznS5mYhg/image_thumb19.png?imgmax=800" width="244" height="162" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click “Finish”.&lt;/p&gt;  &lt;p&gt;3) Now we need to rename your SQL Server installation.&lt;/p&gt;  &lt;p&gt;Start Query Analyser from the “Start/Programs/Microsoft SQL Server” menu. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-ov9SgbHI/AAAAAAAAAYw/gzMnyvyeZkg/s1600-h/image64.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-owQaSKtI/AAAAAAAAAY0/3wyClzc--kA/image_thumb22.png?imgmax=800" width="244" height="187" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Set the SQL Server to be “.” and Connection to Windows authentication and click OK.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-owzC7YFI/AAAAAAAAAY4/LihpJAYxcfQ/s1600-h/image67.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-oxGRDVsI/AAAAAAAAAY8/T8AjvXzl3W4/image_thumb23.png?imgmax=800" width="244" height="101" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;From the Query window type “EXEC sp_dropserver '&amp;lt;old server&amp;gt;'” and click the Play icon.&lt;/p&gt;  &lt;p&gt;Next enter the command in the window “EXEC sp_addserver '&amp;lt;new_name&amp;gt;', 'local' “ and click the Play icon.&lt;/p&gt;  &lt;p&gt;Exit Query Analyser.&lt;/p&gt;  &lt;p&gt;4) From the command prompt type “stsadm -o renameserver -oldservername &amp;lt;old server name&amp;gt; -newservername &amp;lt;new server name&amp;gt;”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-oxl746qI/AAAAAAAAAZA/qThrKHcMUyg/s1600-h/image70.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-ox44GvTI/AAAAAAAAAZE/irTNVk-kV74/image_thumb24.png?imgmax=800" width="244" height="52" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Type Exit and hit &amp;lt;Return&amp;gt; to close the command window.&lt;/p&gt;  &lt;p&gt;5) Open the Registry using REGEDIT command and search for any occurrence of the old server name (i.e. DUBWSDEV010) rename each of these to the new server name (e.g. DUBWSDEV012).&lt;/p&gt;  &lt;p&gt;Play close attention to the key located as “SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Secure\ConfigDB” this should be set to the new server name.&lt;/p&gt;  &lt;p&gt;Restart the server and login as the local Administrator.&lt;/p&gt;  &lt;p&gt;6) Reset the central configuration of sharepoint to the new server by using the administration command: “psconfig -cmd adminvs -provision -windowsauthprovider onlyusentlm”&lt;/p&gt;  &lt;p&gt;7) Reset the external access mappings for the server using Central Administration/Operations/Alternate Access Mappings.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-oyYfou9I/AAAAAAAAAZI/ntO0M36CvQ8/s1600-h/image73.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-oyhZCmtI/AAAAAAAAAZM/d-lrDNtw_4k/image_thumb25.png?imgmax=800" width="244" height="82" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Edit each public URL in your site to match your new server name (e.g. DUBWSDEV012)&lt;/p&gt;  &lt;p&gt;8) In My computer/Properties remove the server from the domain by clicking on Workgroup.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-ozLXS-bI/AAAAAAAAAZQ/fz3SrdnvJiY/s1600-h/image76.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-ozo0pUTI/AAAAAAAAAZU/NUH0CgoxbcI/image_thumb26.png?imgmax=800" width="244" height="157" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Enter “Workgroup” into the field and click OK and restart the server.&lt;/p&gt;  &lt;p&gt;Change the IP address of the server to the one required.&amp;#160; Contact the SharePoint Administrator for your assigned number.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-o0Uzu0XI/AAAAAAAAAZY/RO4QSnANWTA/s1600-h/image79.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-o09iuEaI/AAAAAAAAAZc/B3_dq-sGOKM/image_thumb27.png?imgmax=800" width="244" height="242" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click OK.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-on51GUaI/AAAAAAAAAXg/u0YHnkw6ZvA/s1600-h/image26.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-ooFEkhhI/AAAAAAAAAXk/RF4y1lM3AI8/image_thumb8.png?imgmax=800" width="136" height="68" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Re-enable the network card by right clicking the network icon (last on the right, next to the folder) and select Network Settings. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-o1PhCD-I/AAAAAAAAAZg/b3reo-LE2ao/s1600-h/image82.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-o1tcca3I/AAAAAAAAAZk/Sy9npsL5ugI/image_thumb28.png?imgmax=800" width="244" height="171" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select the Intel card that exists on your host PC and click OK.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Rejoin the domain under the new name by click on My Computer/Properties and select the Domain radio button and enter entirl.com into the field.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-o14h17jI/AAAAAAAAAZs/DawmHggDbXo/s1600-h/image85.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-o2QtjW8I/AAAAAAAAAZw/ku4FwZovRns/image_thumb29.png?imgmax=800" width="244" height="199" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;When prompted for a Username and password, this must be someone with enough permissions to allow this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-o2nP7LfI/AAAAAAAAAZ0/TMuDWZo8MfI/s1600-h/image88.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/S6-o3C6NGWI/AAAAAAAAAZ4/lj13EIwhGb4/image_thumb30.png?imgmax=800" width="244" height="121" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;All going well you should see the following prompt.&lt;/p&gt;  &lt;p&gt;Restart your server, you should now be able to have full access to the local SharePoint environment.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-2023500699012947675?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2023500699012947675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/2023500699012947675'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/03/creating-your-sharepoint-development.html' title='Creating your SharePoint Development Environment'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh6.ggpht.com/_r_B45UywYok/S6-oiK0eFHI/AAAAAAAAAWs/9pP3FeSsprI/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-5833095502660703188</id><published>2009-03-06T01:46:00.001-08:00</published><updated>2009-03-06T01:46:15.110-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Setting up local developers with CCTray</title><content type='html'>&lt;p&gt;In my &lt;a href="http://devrichardagreene.blogspot.com/2009/03/building-continuous-integration-server.html" target="_blank"&gt;last post&lt;/a&gt; I talked about creating a Continuous Integration server and talked about some of the advantages it provides.&amp;#160; Another useful tool that can be used with &lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET" target="_blank"&gt;CruiseControl&lt;/a&gt; is &lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/CCTray" target="_blank"&gt;CCTray&lt;/a&gt;.&amp;#160; This handy little control places an icon in your Windows tasks tray which is Green when all is well, yellow when a build is in progress and Red if a build has failed.&amp;#160; Placing this on all developers machines provides visibility when an error occurs in the build and ensures that all problems are addressed swiftly.&lt;/p&gt;  &lt;h3&gt;Installing CCTray&lt;/h3&gt;  &lt;p&gt;Download the software CruiseControl.NET-CCTray from the &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=71179&amp;amp;package_id=83198" target="_blank"&gt;SourceForge site&lt;/a&gt; and run the setup executable.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/SbDwt7kpewI/AAAAAAAAAN4/uPm13tuktiU/s1600-h/image%5B2%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="192" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/SbDwuoGsDwI/AAAAAAAAAN8/rR4WJtanUjw/image_thumb.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click Next and “I Agree” to the licence agreement.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/SbDwvBClsdI/AAAAAAAAAOA/glldPzlPraI/s1600-h/image%5B5%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="192" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/SbDwvlvULwI/AAAAAAAAAOE/wUt5VRxu91U/image_thumb%5B1%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Take all the default components and click Next.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/SbDwwXZmAbI/AAAAAAAAAOI/oEKOW9o0REc/s1600-h/image%5B8%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="192" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/SbDww46FnVI/AAAAAAAAAOM/lfPmh5ZOXHk/image_thumb%5B2%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select the installation folder and click Next and click Install.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/SbDwxZdRf0I/AAAAAAAAAOQ/UflvvDy61Bg/s1600-h/image%5B11%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="192" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/SbDwyDvFmcI/AAAAAAAAAOU/deqZKoM4Jfc/image_thumb%5B3%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Installation should complete successfully and produce no errors, click “Next” and then “Finished”.&amp;#160; CCTray should appear automatically. on your screen.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/SbDwy9iXleI/AAAAAAAAAOY/jfmdgk87zjA/s1600-h/image%5B16%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="71" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/SbDwzjLRHDI/AAAAAAAAAOc/JJPbZ2KW4V4/image_thumb%5B6%5D.png?imgmax=800" width="411" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Configure CCTray to communicate with the server&lt;/h3&gt;  &lt;p&gt;Once CCTray has been installed you need to select the projects and server on which you want to be notified.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/SbDw0K30oVI/AAAAAAAAAOg/hjJsUR7jGqQ/s1600-h/image%5B19%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="142" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/SbDw00aGgrI/AAAAAAAAAOk/-gXN3T6sLfs/image_thumb%5B7%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Choose File/Settings and tick “Show in Taskbar” then click the “Build Projects Tab”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/SbDw1qRAfuI/AAAAAAAAAOo/B-7WDBC5Keg/s1600-h/image%5B23%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="298" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/SbDw2fIX0WI/AAAAAAAAAOs/bTRD1DkotJM/image_thumb%5B9%5D.png?imgmax=800" width="380" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;On this tab click “Add”, then “Add Server” and on the build server tab select “Connect directly using .NET remoting”. Note: there are other options should you want to work externally, however in this case everything was working on a LAN.&amp;#160; Enter the server name and Click OK.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/SbDw21rI5ZI/AAAAAAAAAOw/pDDUi9O9ka4/s1600-h/image%5B29%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="157" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/SbDw3S1IX2I/AAAAAAAAAO0/n46qQ-LPKPQ/image_thumb%5B11%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Once the server has been validated, it should appear on the left hand side and a list of all valid projects appear on the right.&amp;#160; Select one or more of the projects you want to monitor and press OK.&amp;#160; Once back at the settings dialogue click OK once more.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/SbDw35ZDmdI/AAAAAAAAAO4/dm1B7x8pRg8/s1600-h/image%5B33%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="91" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/SbDw4dXYT6I/AAAAAAAAAO8/rWQaZm3AFmc/image_thumb%5B13%5D.png?imgmax=800" width="391" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now you will be able to see anytime a build has completed by viewing the CC icon in your task tray.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/SbDw453BrcI/AAAAAAAAAPA/cAJ1QkPM0hE/s1600-h/image%5B39%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="34" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/SbDw5feeUxI/AAAAAAAAAPE/d6CwpAImxmQ/image_thumb%5B15%5D.png?imgmax=800" width="140" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-5833095502660703188?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devrichardagreene.blogspot.com/feeds/5833095502660703188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7889773289404691484&amp;postID=5833095502660703188' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/5833095502660703188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/5833095502660703188'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/03/setting-up-local-developers-with-cctray.html' title='Setting up local developers with CCTray'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh3.ggpht.com/_r_B45UywYok/SbDwuoGsDwI/AAAAAAAAAN8/rR4WJtanUjw/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-6826746591293040952</id><published>2009-03-04T08:50:00.001-08:00</published><updated>2009-03-04T08:50:55.810-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Building a Continuous Integration Server</title><content type='html'>&lt;p&gt;Continuous integration refers to the practice of frequently integrating developers code with the code that is already released.&amp;#160; It has a number of advantages for a small development team in that:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;All check-in are checked against the existing code base &lt;/li&gt;    &lt;li&gt;It allows for additional checks such as Unit Tests, code compliance and others to be run automatically. &lt;/li&gt;    &lt;li&gt;It provides developers in the team with instant feedback when errors occur on any application. &lt;/li&gt;    &lt;li&gt;It assists in the release of applications as everything is packaged on the build server and scripted correctly. &lt;/li&gt;    &lt;li&gt;As builds are taken only from a source control database, it ensures that all information and scripts have been stored before an application can be released. &lt;/li&gt; &lt;/ol&gt;  &lt;h3&gt;Installation on the server&lt;/h3&gt;  &lt;p&gt;To run a continuous integration build server you need the following applications installed.&lt;/p&gt;  &lt;p&gt;Windows 2003 Server R2    &lt;br /&gt;IIS     &lt;br /&gt;Visual Studio 2008     &lt;br /&gt;Source Safe Client     &lt;br /&gt;.Net Framework 3.5     &lt;br /&gt;&lt;a href="http://sourceforge.net/project/showfiles.php?group_id=71179&amp;amp;package_id=83198" target="_blank"&gt;Cruise Control.net&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=ccnetconfig" target="_blank"&gt;CCNetConfig&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Assuming that the server has been built using the standards set down the additional tools are installed as follows:&lt;/p&gt;  &lt;h5&gt;CruiseControl.Net&lt;/h5&gt;  &lt;p&gt;Run the executable that is downloaded from SourceForge.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/Sa6xFnSs-FI/AAAAAAAAALo/WSM4DV-kGw0/s1600-h/image5.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="186" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/Sa6xGM-Jc3I/AAAAAAAAALs/L_ncwDsHpc4/image_thumb1.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click “Next”, click “I Agree” to the licence agreement and Next selecting all default components.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/Sa6xGqy-nSI/AAAAAAAAALw/orHSo3ajMW8/s1600-h/image11.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="190" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/Sa6xHENI-vI/AAAAAAAAAL0/lyuVEl3TiTw/image_thumb3.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select both options and click Next.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/Sa6xHfVaVOI/AAAAAAAAAL4/d9l-sRGFNg0/s1600-h/image14.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="190" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/Sa6xIMheqhI/AAAAAAAAAL8/SiQoB43idNc/image_thumb4.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Set the destination folder and click Next and finally click “Install”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/Sa6xIkEyztI/AAAAAAAAAMA/zpvCX2K05p8/s1600-h/image20.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="189" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/Sa6xJLBUaNI/AAAAAAAAAME/JLxqVYHj1Ik/image_thumb6.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Once installation has completed click “Next” and click Finished.&lt;/p&gt;  &lt;h5&gt;CruiseControl.Net&lt;/h5&gt;  &lt;p&gt;Run the executable that is downloaded from CodePlex.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/Sa6xJuDbR_I/AAAAAAAAAMI/l-XtoGq3F4M/s1600-h/image23.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="191" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/Sa6xKH9JW-I/AAAAAAAAAMM/TK-Qq-VVq9c/image_thumb7.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click Next and accept the licence agreement and click “Next”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/Sa6xKraWNrI/AAAAAAAAAMQ/4NExDVTERTg/s1600-h/image26.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="190" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/Sa6xLaofSYI/AAAAAAAAAMU/Mq8feQlnS-Y/image_thumb8.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Set the destination folder and click “Next” and finally click “Install”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/Sa6xLst5CrI/AAAAAAAAAMY/l_gng8jdbWY/s1600-h/image29.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="188" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/Sa6xMcvYaFI/AAAAAAAAAMc/QqosrhjMYeU/image_thumb9.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Once installation have completed click “Finish”.&lt;/p&gt;  &lt;h3&gt;Configuration of the build projects&lt;/h3&gt;  &lt;p&gt;Each application should have it’s own project within the CruiseControl.Net application.&amp;#160; Each project is basically a set of tasks which are described using XML and stored in the CCNet Server Configuration file.&amp;#160; These files can get quite long and complicated, which is the reason we use the CCNetConfig application which provides a simple point and click interface.&lt;/p&gt;  &lt;p&gt;Open the CCNet Config application, using Start/All Programs CCNet Config/CCNetConfig.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/Sa6xNACzMuI/AAAAAAAAAMg/8nCxJ3uqKgg/s1600-h/image33.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="232" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/Sa6xNgKM87I/AAAAAAAAAMk/LLhiYDdlqbE/image_thumb11.png?imgmax=800" width="298" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;When the application starts choose file/Open from the menu and browse to the location of the CruiseControl directory.&amp;#160; Within the server folder you’ll find a file called ccnet.config, select this file and set the version combo box to the version of CruseControl you are using.&amp;#160; In this case it was 1.4 and click “Open”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/Sa6xOfLIpyI/AAAAAAAAAMo/mzz912BL-wA/s1600-h/image39.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="157" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/Sa6xPKKt4LI/AAAAAAAAAMs/R4xH3sOcLbA/image_thumb13.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Assuming you’re starting for the first time you will only see two entries in the tree, select the first “CruiseControl” and click the first icon in the tool bar to create a project.&amp;#160; You will see a dialogue appear, in which you enter a meaning name for the project you’re trying to place in continuous integration.&amp;#160; In this case I’m using “Debug – CryRptCom” which is a debug build of a small Visual Studio 2008 project.&amp;#160; Click OK and the entry should appear in the tree on the left.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/Sa6xP_kZK2I/AAAAAAAAAMw/pxp9wCFo5b0/s1600-h/image54.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="176" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/Sa6xQhpnPpI/AAAAAAAAAM0/vmUCivvSVB0/image_thumb18.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Once the project is created expand the tree node and the select Tasks node and fill in the required information such as the working directory for the project, account to access SrouceControl, etc.&amp;#160; &lt;/p&gt;  &lt;p&gt;Note: Create a folder named “buildlogs” folder in the working directory selected or the build will fail. &lt;/p&gt;  &lt;p&gt;Once that has been completed right click the Triggers node and and select “Add Trigger/IntervilTrigger”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/Sa6xRP_2VmI/AAAAAAAAAM4/capjoX4-X_I/s1600-h/image77.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="164" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/Sa6xR6Q_TWI/AAAAAAAAAM8/vCRHYNQQtas/image_thumb27.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Enter the information needed to trigger a build, in this case If a change exists in source Control and wait 120 seconds before testing for the next change.&lt;/p&gt;  &lt;p&gt;Once that has been completed right click the Tasks node and and select “Add Task/Visual Studio Task”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/Sa6xSpw_fvI/AAAAAAAAANA/6jSLN_FxX94/s1600-h/image60.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="160" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/Sa6xTTJs2II/AAAAAAAAANE/y3jcR5kntu8/image_thumb20.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Enter the information needed to build the code Using Visual Studio 2008.&lt;/p&gt;  &lt;h5&gt;Starting the CruiseControl Service&lt;/h5&gt;  &lt;p&gt;Once the project has been configured you need to start (or restart)&amp;#160; the CuriseContorl service in order for the changes to be read.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/Sa6xUBK3PvI/AAAAAAAAANI/96biHmJk9ek/s1600-h/image42.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="178" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/Sa6xUsF7IeI/AAAAAAAAANM/0dKJKrgfuGg/image_thumb14.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;From the Control Panel/Administrative Tools, select Services and select the CruiseControl.Net, then click the Start icon on the tool bar.&amp;#160; the Service should start without any errors.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Accessing Cruise Control from a developers client&lt;/h3&gt;  &lt;p&gt;The Cruise Control application creates a website by default which is used to interacted with the client application.&amp;#160; In this case the development server URL is &lt;a href="http://miranda/CCnet/"&gt;http://miranda/CCnet/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/Sa6xVTHOeWI/AAAAAAAAANQ/huUhHDExJoc/s1600-h/image45.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="193" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/Sa6xVx19OvI/AAAAAAAAANU/efQWml24jO8/image_thumb15.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;You should see the project you have entered into the configuration screen.&amp;#160; Now you can click the “Force” button to build the application on the server.&amp;#160; This will get the latest version of the application from source control, download it to the server and build everything.&amp;#160; If it passes all the test correctly it will show a green “Success” message in the last build status column.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/Sa6xWqNX8ZI/AAAAAAAAANY/2EQgGtDa82M/s1600-h/image63.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="216" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/Sa6xXQHomAI/AAAAAAAAANc/QnvBLeyoLjI/image_thumb21.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The process is also running continually, so if any developer tries to check in code which does not compile for example as I did here be commenting out a sting.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/Sa6xYAvjrJI/AAAAAAAAANg/0YcXjvDrxMU/s1600-h/image67.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="261" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/Sa6xYm5w4aI/AAAAAAAAANk/KGvmz-bkVVA/image_thumb23.png?imgmax=800" width="336" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;After a few seconds the CruiseControl will report the error. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/Sa6xZlRR_2I/AAAAAAAAANo/VXhiL2YVB5k/s1600-h/image70.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="217" alt="image" src="http://lh5.ggpht.com/_r_B45UywYok/Sa6xaBZyO6I/AAAAAAAAANs/adRo-ZFBw-U/image_thumb24.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;a href="http://lh3.ggpht.com/_r_B45UywYok/Sa6xa2Xt2FI/AAAAAAAAANw/kGIh7Cv_o1Q/s1600-h/image74.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="216" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/Sa6xbkpeMAI/AAAAAAAAAN0/ETaxmcdk_nc/image_thumb26.png?imgmax=800" width="313" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click on the project link to get the error message… and as you can see “rgreene” was the last person to access the files and you also see the comment used for the check-in.&amp;#160; After fixing the error and checking in you will see that the project goes back to green status. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-6826746591293040952?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devrichardagreene.blogspot.com/feeds/6826746591293040952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7889773289404691484&amp;postID=6826746591293040952' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6826746591293040952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/6826746591293040952'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/03/building-continuous-integration-server.html' title='Building a Continuous Integration Server'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh4.ggpht.com/_r_B45UywYok/Sa6xGM-Jc3I/AAAAAAAAALs/L_ncwDsHpc4/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-7310747719788776081</id><published>2009-02-25T10:54:00.000-08:00</published><updated>2010-03-28T11:55:10.613-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Unrecognized attribute 'xmlns'.</title><content type='html'>&lt;p&gt;If you ever the the error message “Unrecognized attribute 'xmlns'.” appear in the browser.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-mA9ZLwQI/AAAAAAAAAWQ/IwBnMlsjMGk/s1600-h/image3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-mBUi5vGI/AAAAAAAAAWU/ZEhIWnsQ2cs/image_thumb1.png?imgmax=800" width="517" height="228" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;the reason is because the .NET framework is set to version 1.1 and not 2.0.&amp;#160; To fix this open IIS and right click the virtual directory, in this case CSSSearch and select Properties from the menu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-mCBDpt7I/AAAAAAAAAWY/ZBiopBZJYts/s1600-h/image6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-mCRaxVqI/AAAAAAAAAWc/oDIguqRl_qU/image_thumb2.png?imgmax=800" width="244" height="175" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click the ASP.NET tab and change the ASP.NET version to 2.0.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-mC10xPrI/AAAAAAAAAWg/jKTzaeVctJk/s1600-h/image9.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_r_B45UywYok/S6-mDS-lngI/AAAAAAAAAWk/EKHzUBTHICY/image_thumb3.png?imgmax=800" width="244" height="237" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Click OK and that should be it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-7310747719788776081?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/7310747719788776081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/7310747719788776081'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/02/unrecognized-attribute.html' title='Unrecognized attribute &amp;#39;xmlns&amp;#39;.'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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://lh6.ggpht.com/_r_B45UywYok/S6-mBUi5vGI/AAAAAAAAAWU/ZEhIWnsQ2cs/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-909343176831390675</id><published>2009-02-22T08:21:00.000-08:00</published><updated>2009-02-22T08:36:54.892-08:00</updated><title type='text'>Linq extensions missing</title><content type='html'>I recently had a project to do using the new Microsoft Entity Framework, which gave me a serious bit of head scratching to do.  The problem was that I had created a model as usual and created a controller class as usual; however compiling the code below gave me the error:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;'System.Data.Objects.ObjectQuery&lt;SupplierProductEntityFrameworkLib.Model.Products&gt;' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'System.Data.Objects.ObjectQuery&lt;SupplierProductEntityFrameworkLib.Model.Products&gt;' could be found (are you missing a using directive or an assembly reference?)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;        public object GetSuppliers()&lt;br /&gt;        {&lt;br /&gt;            ObjectQuery&lt;Suppliers&gt; supplierQuery;&lt;br /&gt;            using(NorthwindEntities northwindContext = new NorthwindEntities())&lt;br /&gt;            {&lt;br /&gt;                supplierQuery = northwindContext.Suppliers;&lt;br /&gt;            }&lt;br /&gt;            return supplierQuery.ToList();&lt;br /&gt;        }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;WTF?  Hang on I've used code like this dozens of times before and never got this error before.  It took quite a time for me to figure out that when the class was created by Visual Studio it had failed to add the usual &lt;span style="font-weight:bold;"&gt;using System.Linq; &lt;/span&gt; line at the top.  &lt;br /&gt;&lt;br /&gt;This lead me to think, why this was the case and I found this &lt;a href="http://www.devsource.com/c/a/Languages/Extension-Methods-LINQ/"&gt; interesting article &lt;/a&gt;which describes extension methods.  &lt;br /&gt;&lt;br /&gt;Simple once you know the answer.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7889773289404691484-909343176831390675?l=devrichardagreene.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/909343176831390675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7889773289404691484/posts/default/909343176831390675'/><link rel='alternate' type='text/html' href='http://devrichardagreene.blogspot.com/2009/02/linq-extensions-missing.html' title='Linq extensions missing'/><author><name>Richard A. Greene</name><uri>http://www.blogger.com/profile/14020911453292043423</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></entry><entry><id>tag:blogger.com,1999:blog-7889773289404691484.post-1382509991610283273</id><published>2009-02-19T10:52:00.000-08:00</published><updated>2010-03-28T11:52:57.662-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Development'/><title type='text'>Adding the Firebug plug-in to FireFox</title><content type='html'>&lt;p&gt;I love firebug, I’d go as far as saying the main reason you’d want to download the browser to use use this fantastic little bit of functionality.&amp;#160; This handy little tool allows for the debugging, editing, and monitoring of any website's CSS, HTML or JavaScript.&amp;#160; It’s also very handy for working with JQuery.&lt;/p&gt;  &lt;h3&gt;Adding Firebug to your browser&lt;/h3&gt;  &lt;p&gt;First you need a copy of Firefox which you can get from the &lt;a href="http://www.mozilla.com/en-US/firefox/" target="_blank"&gt;web&lt;/a&gt;.&amp;#160; (Note: you should be on FireFox v3 or higher to use FireBug) &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-lZ1SX3YI/AAAAAAAAAVA/Y-ycLVrA65g/s1600-h/image2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-laRPGD5I/AAAAAAAAAVE/BS6MVEpqQ70/image_thumb.png?imgmax=800" width="244" height="144" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Once you’ve started Firefox go to Tools/Add-ins from the menu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_r_B45UywYok/S6-la6LDL7I/AAAAAAAAAVI/as07LdN2a8Q/s1600-h/image12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-lbJl_RkI/AAAAAAAAAVM/PYqH0FrTZSU/image_thumb4.png?imgmax=800" width="244" height="160" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Click “Get Add-on” in the upper left hand corner and type “FireBug” into the search field below and hit Enter..&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-lbtta0ZI/AAAAAAAAAVQ/W-ffrqGHmZI/s1600-h/image15.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_r_B45UywYok/S6-lcPIXPaI/AAAAAAAAAVU/Z5r4IhZibCQ/image_thumb5.png?imgmax=800" width="244" height="160" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Firebug should be the first one returned.&amp;#160; Click the “add to Firefox” button&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_r_B45UywYok/S6-lclTGfBI/AAAAAAAAAVY/Pbfw50_QwZ8/s1600-h/image18.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-lc60xAAI/AAAAAAAAAVc/vRqGoyn5Xw8/image_thumb6.png?imgmax=800" width="244" height="170" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click the Install Now button and close the Add-In window and restart FireFox.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_r_B45UywYok/S6-ldAONboI/AAAAAAAAAVg/Sv2C4BCiUew/s1600-h/image21.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_r_B45UywYok/S6-ldsVa6VI/AAAAAAAAAVk/w9iOquX1eUg/image_thumb7.png?imgmax=800" width="121" height="64" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now you should be able to see the Firebug logo in the bottom right Hand corner, click this at any time to start the Add-in.&lt;/p&gt;  &lt;h3&gt;Using Fire Bug to view HTML and run Scripts.&lt;/h3&gt;  &lt;p&gt;On any webpage click the bug icon.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_r_B45UywYok/S6-ld4D8iQI/AAAAAAAAAVo/KC4BVfmWxrI/s1600-h/image26.png"&gt;&lt;img style="border-right-widt
