Recent Posts

Categories

Archives

Calendar

July 2009
M T W T F S S
« Jul    
 12345
6789101112
13141516171819
20212223242526
2728293031  

Search


Meta

Installing Subversion on Windows

My requirements are to host the repository on a windows machine, mostly for access from the LAN but also to be accessible over the Internet. The server is running Vista but the install and set up process should be similar on other versions of windows.

Currently there are two relevant builds of Subversion, one based on apache 2.0 and one based on 2.2. I am going to install Apache 2.2 and the corresponding Subversion build.

Install the Apache HTTP server.

Download and run the latest subversion build (currently svn-1.4.6-setup.exe) from http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=8100&expandFolder=8100&folderID=91

Copy the file mod_dav_svn.so from C:\Program Files\Subversion\bin to C:\Program Files\Apache Software Foundation\Apache2.2\modules.

Open the Apache configuration file (‘Start > All Programs > Apache HTTP Server 2.2 > Configure Apache Server > Edit the Apache httpd.conf Configuration File’) and find the line ‘#LoadModule dav_module modules/mod_dav.so’.

Remove the ‘#’ from the front of that line then add the line ‘LoadModule dav_svn_module modules/mod_dav_svn.so’ below it. Save the file and restart the service to confirm everything is working as it should.

Create the directory where you want to store the repositories (e.g. D:\Svn).

Go back to the Apache configuration file and at the end of the file add:

<Location /Svn>
    DAV svn
    SVNListParentPath on
    SVNParentPath D:\Svn
</Location>

Save the changes then restart the Apache service for them to take effect.

You should now be able to browse to http://localhost:81/Svn/ and see a page with zero repositories.

Installing Apache HTTP Server on Windows

I am setting up a machine to host Subversion. My preference is to use Apache as the HTTP server. The server is running Vista but the install and set up process should be similar on other versions of windows.

Download
The latest Apache build (currently apache_2.2.9-win32-x86-no_ssl-r2.msi) from http://httpd.apache.org/download.cgi

Install Apache
Run the installer and follow the instructions. Enter the server name under ‘Network Domain’ and ‘Server Name’, enter an email address and leave ‘for All Users’ selected.
ApacheInstall

Navigate to http://localhost/ and you should see the text ‘It works!’.

I prefer to run IIS on port 80 and Apache on 81. If you already have IIS installed and running you may not have got the ‘It works!’ page but rather an IIS page when running the test above.

Change to Port 81
‘Start > All Programs > Apache HTTP Server 2.2 > Configure Apache Server > Edit the Apache httpd.conf Configuration File’

Search for  ‘Listen 80′ and replace with ‘Listen 81′

Save the conf file and restart the service from the services console then browse to http://localhost:81/ to confirm it works.

Create a Password File
Open a command prompt at C:\Program Files\Apache Software Foundation\Apache2.2.

Create a password file by entering ‘bin\htpasswd -c passwd username‘ and enter and confirm the password when prompted.

Add any further users with ‘bin\htpasswd passwd username‘.

Edit the Apache httpd.conf configuration file and change:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

To:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    AuthType Basic
    AuthName “Subversion Repositories”
    AuthUserFile passwd
    Require valid-user
</Directory>

Restart the Apache 2.2 service and confirm you are asked for a username and password when you navigate to http://localhost:81/.

You may need to amend your firewall to allow connections from port 81.
ApacheWindowsFirewall

Vista “Windows Complete PC Restore” fails with “No valid backup locations could be found”

There is an issue with Vista complete PC back up and restore if you are restoring to a clean system from more than one DVD or CD. It appears that the catalogue is stored on the last disc in the back up set but this appears to be undocumented.

This means when you run your Windows Complete PC Restore, either from Vista or by choosing repair your computer during an installation, and insert the first disk of the back up when asked to insert the backup media you get the message “No valid backup locations could be found” which initially is just a bit worrying.

If you insert the last disk of the backup set, the catalogue is found and you can choose the backup and the backup options you want. When the backup starts you will be asked to insert the first disk.

Simple Thread Safe Singleton

This is simple but should work:

public sealed class Singleton
{
   private static Singleton _instance = new Singleton();

   private Singleton() { }

   public static Singleton Instance
   {
      get
      {
         return _instance;
      }
   }
}

As the CLR synchronises static constructors it is thread safe. Also static constructors are not called until the types is accessed to you have lazy instantiation (use nesting if there are other static methods).

Run this program as program as an administrator

Vista will try and run most programs without admin rights even if you are signed on as an admin. Some programs such as Visual Studio need admin rights so it is worth setting them to always run as administrator.

Confusingly, looking at a shortcut’s properties, the compatibility tab has an option to “Run this program as an administrator”. This option is greyed out:

Shortcut Compatibility Tab

To set the shortcut to run as administrator go to the shortcut tab > click on Advanced… > check Run as administrator:

Shortcut Advanced Properties

 

Macro to Set Outlook’s Master Category List

I upgrade, move, or reinstall the OS on my PCs fairly often so setting a master category list with a macro is useful:

Public Sub ResetCategories()

    DeleteAllCategories
   
    CreateCategory “! goals”, 1, 0
    CreateCategory “! objectives”, 2, 0
    CreateCategory “! projects”, 3, 0
    CreateCategory “@ anywhere”, 4, 0
    CreateCategory “@ computer”, 5, 0
    CreateCategory “@ email”, 6, 0
    CreateCategory “@ errands”, 7, 0
    CreateCategory “@ home”, 8, 0
    CreateCategory “@ office”, 9, 0
    CreateCategory “@ phone”, 10, 0
    CreateCategory “1:1″, 11, 0
    CreateCategory “2 inbox”, 23, 1
    CreateCategory “2 someday maybe”, 24, 0
    CreateCategory “2 waiting for”, 19, 0
    CreateCategory “meeting”, 22, 0
    CreateCategory “holiday”, 17, 0
    CreateCategory “social”, 18, 0
    CreateCategory “STS”, 20, 0
    CreateCategory “travelling”, 21, 0
    CreateCategory “cards”, 25, 0
   
End Sub

Private Sub DeleteAllCategories()
    Dim objNameSpace As NameSpace
    Dim objCategory As Category
   
    Set objNameSpace = Application.GetNamespace(”MAPI”)
   
    If objNameSpace.Categories.Count > 0 Then
       
        For Each objCategory In objNameSpace.Categories
            objNameSpace.Categories.Remove (objCategory.CategoryID)
        Next
       
    End If
       
    Set objCategory = Nothing
    Set objNameSpace = Nothing
   
End Sub

Private Sub CreateCategory(strCategoryName As String, intColor As Integer, intKey As Integer)
    Dim objNameSpace As NameSpace
    Dim objCategory As Category
   
    Set objNameSpace = Application.GetNamespace(”MAPI”)
   
    If intColor > 25 Then intColor = -1
   
    objNameSpace.Categories.Add strCategoryName, intColor, intKey
       
       
    Set objCategory = Nothing
    Set objNameSpace = Nothing
   
End Sub

Outlook Item to Task Macro

The following macros convert outlook items to tasks with different categories. Based on this blog post which in turn is based on this one.

  • The item body is copied to the task body and the item itself is added as an attachment.
  • If multiple items are selected, multiple tasks will be created.
  • Created tasks are left open for editing.
  • I am in two minds about deleting the item after the task is created and have decided against it at the moment.
  • It appears that OL 2007 does not allow shortcut keys to be assigned to macros .

Public Sub CreateInboxTaskFromItem()
    CreateCatagorisedTaskFromItem (”2 inbox”)
End Sub

Public Sub CreateWaitingTaskFromItem()
    CreateCatagorisedTaskFromItem (”2 waiting for”)
End Sub

Public Sub CreateSomedayTaskFromItem()
    CreateCatagorisedTaskFromItem (”2 someday maybe”)
End Sub

Public Sub CreateTaskFromItem()
    CreateCatagorisedTaskFromItem (”")
End Sub

Private Sub CreateCatagorisedTaskFromItem(catagory As String)

  Dim olTask As Outlook.TaskItem
  Dim olItem As Object
  Dim olExp As Outlook.Explorer
  Dim fldCurrent As Outlook.MAPIFolder
  Dim olApp As Outlook.Application
 
  Set olApp = Outlook.CreateObject(”Outlook.Application”)
  Set olExp = olApp.ActiveExplorer
  Set fldCurrent = olExp.CurrentFolder
 
  Dim cntSelection As Integer
  cntSelection = olExp.Selection.Count
 
  For i = 1 To cntSelection
    Set olTask = olApp.CreateItem(olTaskItem)
    Set olItem = olExp.Selection.Item(i)
    olTask.Attachments.Add olItem
    olTask.Body = olTask.Body + olItem.Body
    If catagory = “2 waiting for” Then
        olTask.Subject = olItem.SenderName & “: ” & olItem.Subject
    Else
        olTask.Subject = olItem.Subject
    End If
    olTask.Categories = catagory
    ‘olItem.Delete
    olTask.Display
    olTask.Save
  Next
 
End Sub

Vista Install Blank Screen

Trying to install Vista on a machine and getting a blank screen after one of the reboots?

This could be caused by an incompatible display driver. I solved this problem by:

  1. Reboot the machine and hit F8 to get the Windows boot menu.
  2. Select Safe Mode with Networking.
  3. Vista will boot then will complain that it cannot continue with the installation in Safe Mode. Do not hit OK!
  4. Press Shift + F10 to get a command window.
  5. Run Device Manager by entering ‘devmgmt.msc’.
  6. Right click the video card and select Update Driver.
  7. Choose ‘Select a Driver’.
  8. Select ‘Choose from a list’.
  9. Click on the generic VGA driver and hit Next to install it.
  10. Close the wizard, close the Device Manager, close the command prompt.
  11. Click OK on the installation message and Vista will reboot.
  12. Finish the install, create a restore point, then install the correct video driver.

How to Use InternalsVisibleTo

VS2005 defaults new classes to internal rather than public (although it appears that Orcas defaults to public). This is good as it reduces the public interface of your assembly and it encourages you to actually think about whether a class needs to be public.

You can allow other assemblies access to your internal types and members though, by using the InternalsVisibleTo attribute. This is especially useful for allowing your test assembly to access your internal classes.

This attribute can only be applied to strongly named assemblies.

[assembly:InternalsVisibleTo(”TestAssembly, PublicKey=TestAssembly’s public key“)]

The attribute requires the assembly name and the public key. To retrieve the public key use sn.exe. Open a visual studio command prompt and enter:

sn.exe -Tp AssemblyPath

Alternatively if you use an alternate file explorer you could set up a macro.

This page has an unspecified potential security risk.

With Vista (and probably XP and IE7) right clicking on a zip file on a network share brings up an Internet Explorer dialogue:

This page has an unspecified potential security risk. Would you like to continue?

It appears that the OS thinks that your network share is in the Internet Zone rather than the Intranet Zone. This is easily fixed by:

  1. Control Panel > Internet Options > Security.
  2. Select Local intranet > click Sites > Advanced.
  3. Type your server name into the textbox (e.g. If the server is called FileServer just type FileServer) and click Add.
  4. Click Close > OK > OK.

« Previous Entries