After reviewing the service wrapper for Subversion that is available at http://svnservice.tigris.org/, I found that for the environment that I work in, we need to run multiple instances of the service, but I wanted to make it one service that is installed onto our server. Given that the Subversion server uses a very small (at least mine are) memory footprint, I came up with the idea of having the one service run multiple instances of the SVN server.
I also wanted the project to be able to be run purely as an Exe for the purposes of testing. We actually employ a strategy similar to this for another project so that our developers can run the program on their machine (without the requirement for the service installation), enabling the debugging of assemblies easier.... but that is another article
Points of Interest
Given that it has been identified in the comments that this could be done easier using the Directory approach, hopefully someone will find it useful for the ability to host a Service and a regular WinForms application in one executable.
Setting up the Project
To create this project, you just use VS.NET to create a Windows Service application. This will create the necessary project files etc. You now will need to make some modifications to the sub
Main to allow the application to run as a Service or as an application.
Setting the Service
To make the program be able to run in the correct mode, we will need to modify ServiceInstaller.vb so that when the service is installed, it will modify the command line parameters that are sent to the application.
We make our
Main function in the service examine the command line to determine that these parameters have been supplied.
If Environment.GetCommandLineArgs.GetUpperBound(0) > 0 Then
theArgs = theArgs.Substring(theArgs.IndexOf("/"))
Dim collectionArgs() As String
collectionArgs = theArgs.Split("/"c)
Dim i As Integer
For i = 1 To collectionArgs.GetUpperBound(0)
Dim strParameterValue() As String
strParameterValue = collectionArgs(i).Split("="c)
Select Case strParameterValue(0).ToLower
If strParameterValue(1).ToLower = "service" Then
blnService = True
blnService = False
Now that we have run, we need to start the service, or run the application.
If blnService Then
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
ServicesToRun = New System.ServiceProcess.ServiceBase() _
Diagnostics.Process.GetCurrentProcess.ProcessName).Length <= 1 Then
Dim systemOperation As Start
systemOperation = New Start(configFile)
To see the intimate details of this, examine the source code in the "ServiceController.vb" and "Start.vb" files.
Setting up the Application
We use a
ListView control presenting the information about the processes that we have created and the ports that we have running.
Setting up the ASP.NET page
The page is very simply a web based version of the application except that it enables you to click a link if you have TortiseSVN installed, and it will redirect you to that location.
Why am I looking at Subversion
I have been using SourceSafe for most of the development projects I have been involved with since I started working on the Windows platform around 10 years ago. After listening to Hanselminutes, I have been hearing and reading nothing but good things about Subversion. I also recently examined our SourceSafe to find that it had corrupted itself (fortunately, only a couple of files). Therefore, I have started showing our other developers the pros of Subversion with little to none of the cons associated with SourceSafe.
The speed at which check-in and out (Add, Update, Commit) are done is just outstanding.
Where to From Here
I will be revising the program to enable commands to be sent to the Service to perform a backup (and compress the backup), and also stop/start/restart a specific instance of the Subversion repository that is being run.
Bugs? What Bugs?
In the testing I have done, I haven't found any, but if you do, please let me know. I have tested this in Win2000, WinXP, and Win2003.