Tuesday, April 15, 2008

A SIMPLE .NET Subversion Trigger

April 15, 2008 Posted by Jason , , 1 comment
This latest post finds me on my continued Subversion kick. Having checked out the wonderful, yet not quite mature enough Mercurial and the possibly wonderful but completely painful windows experience of GIT, i'm sticking with Subversion as my Visual SourceSafe replacement of choice. This week I have mostly been playing with Subversion hooks- an extremely simple and powerful trigger mechanism used when checking items in or out of a subversion database.

For those who do not know, each subversion database contains a 'hooks' folder in which files exist for pre and post commit/lock/property change/unlock events. Harnessing this hooking mechanism is as simple as creating a file and giving it, for instance the filename 'pre-commit'. The true beauty (i'm sure i mentioned this before) is that the extension doesnt matter - you can use an exe, a batch file, a .pl file etc. etc. and, as long as your filename falls into the pre-defined list, your hook is guaranteed to run on the chosen event. Some templates are created as part of the default database creation, and below is an example of a pre-commit.tmpl script for one of my databases.

The beauty of this example is that it explains in no uncertain terms the paramaters taken by the hooking procedure:

# [1] REPOS-PATH (the path to this
# [2] TXN-NAME (the name of the txn
about to be committed)

Using these parameters, it is easy to create triggers in the flavor of your choice. Below, i created a VB.NET console application which (given the repository path and transaction name) uses the external svnlook command to inspect the comment field passed as part of the transaction. If the user has entered comments less than 5 characters (an arbitrary number) the transaction will fail (a la the exit(1) command and will write an error message back to the calling application.

Here's a screenshot of TortoiseSVN when this trigger fires and my limit of 5 characters had not been reached.

I've been working on something a little more substantial for next time, but I hope this serves as a pretty simple introduction to the joys of subversion triggers!

The service could not bind instance 1

April 15, 2008 Posted by Jason , , No comments
In work this morning I attempted to fire up Visual Studio with an ASP.NET application I hadn’t used in a while only to receive an error message stating that the project could not be mapped to an IIS application. Looking deeper I found that the application did indeed exist, but IIS was not behaving nicely – a big STOP sign replacing my normally very pleasant default web site icon. The Event Viewer should the following error:

Event Type: Error
Event Source: W3SVC
Category: None
Computer: MYPC
service could not bind instance 1. The data is the error code.
additional information specific to this message please visit the Microsoft
Online Support site located at:

For more information,
see Help and Support Center at
0000: 40 27 00

A little trial and error and I found the issue and simple solution. Port 80, used by IIS was also being used by Apache which I had recently installed on my local box. Shutting down Apache allowed IIS to restart correctly, and from there I could (if I so chose) change the default port on Apache thereby permanently fixing this issue. Simple!