Thursday, 21 August 2008

FindControl Causes Null Reference Exception with NMock

When using NMock on code that uses FindControl, a null reference exception is thrown:

PlaceHolder placeHolder =

(PlaceHolder) _view.MyPanel.FindControl("myplaceholder");

You could use the indexer instead:

PlaceHolder placeHolder =

(PlaceHolder) _view.MyPanel.Controls[0];

But if you insert another control in the panel, you break your code. So, the alternative is to loop through the controls and find a match by ID:

ControlCollection ctrls = _view.MyPanel.Controls;

foreach( Control ctrl in ctrls )
{
if( ctrl.ID == "myplaceholder" )
{
placeHolder = (PlaceHolder) ctrl;
break;
}
}

Saturday, 2 August 2008

CruiseControl builds not working

Here's a quick checklist to assist in getting failed builds working again in CruiseControl.NET:
  • Comment out any custom tasks, such as running unit tests, in the ccnet config file (defined within <exec> elements)
  • Find error details quickly within the build log by searching for the following words/phrases:
    • could not
    • failed
    • success="false"
  • Check whether the code compiled without error by:
    • Running the project's team build as used by CCNET
    • Searching for "csc" (or "vbc") in the build log
  • Clear out temporary files on the build server to remove any sticky references

Wednesday, 23 July 2008

TechEd Video

I recently discovered Animoto, so here's a quick video of my time at TechEd:

Friday, 18 July 2008

Could not find property 'Name' on object of type: Sitecore.Data.SqlServer.SqlServerDataProvider

This week, I branched a solution in TFS and checked out the branch. It built successfully. I then added virtual directories in IIS to point at the locations of the app_config, sitecore, sitecore modules and data folders (I move these outside of the web site root for easier swappability and source control). On browsing to the site, I got the message:

Could not find property 'Name' on object of type: Sitecore.Data.SqlServer.SqlServerDataProvider

It took a while to figure out that this was due to the assemblies in source control being out of date. Once I'd copied the contents of the bin folder on the live web server to my local machine, I was able to browse the site.

Tuesday, 8 July 2008

Creation of the virtual directory http://localhost/ failed

On attempting to check out a project in VS2008, I got the following message:

The local IIS URL http://localhost/ specified for Web project DemoWebsite has not been configured. In order to open this project the virtual directory needs to be configured. Would you like to create the virtual directory now?

On clicking yes, I got the following error:

Creation of the virtual directory http://localhost/ failed with the error: The URL 'http://localhost/' is already mapped to a different folder location.

The rest of the solution checked out all right, but the above project did not; it was marked as unavailable. I right-clicked the project node in the solution explorer and selected the option to edit the project (.csproj) file. Near the bottom of the file, I found the following:

<iisurl>http://localhost/</iisurl>

I edited this entry to add a virtual directory:

<iisurl>http://localhost/myapp</iisurl>

Having saved the change, I then right-clicked the project node in the solution explorer again and reloaded the project. When I was prompted to create the virtual directory again, the creation was successful and the project checked out. The virtual directory is created under the running web site in IIS (on Windows XP).

Thursday, 12 June 2008

Songs and bands likely to appeal to IT nerds

This list was compiled with the "help" of colleagues. Feel free to add to these bad puns.
  • Motley Cruise Control
  • Status Disk Quota
  • Visio Killed the Radio Star (by De-Buggles)
  • Iron Python Maiden
  • The Google Dolls
  • USB-40
  • InXSlt
  • Fleetwood (Apple) Mac
  • Bob Marley and the E-mailers
  • Sonny and SharePoint
  • Black-eyed ASPs
  • CultureInfo Club
  • Re-bootylicious
  • System of a Downtime
  • Billy Blu-Ray Cyrus
  • Snoop Blogg
  • Shania Twain interface
  • Silverlight Lady
  • Public Image Limited Disk Space
  • Don't believe the hyperterminal
  • Token Ring of Fire (by Jonny Cache)
  • Awk This Way (by Runas /user:DMC)
  • Wired for soundcard
  • Dragonforce shutdown
  • Bat out of HTML
  • Earth, Wind and Firewire
  • MPEGgy Sue
  • Great balls of Firefox
  • Alien Ant Web Farm
And my personal favourite:

Adam and the NAnts

[Edited 8 Oct 2008]

Monday, 12 May 2008

TableHeaderScope enum does not generate XHTML-compliant output

When adding the scope attribute to a column for accessibility, the following does not generate XHTML-compliant output:

TableHeaderCell th = new TableHeaderCell();
th.Scope = TableHeaderScope.Column;

It generates the following HTML:
<th scope="column">

The value of the scope attribute should be "col". A work-around is to add the scope attribute manually using the Attributes collection:

th.Attributes.Add("scope", "col");