Monday, January 29, 2007

Installing Windows Service developed with .NET 2.0

Problem

How to install windows service developed with .NET 2.0 without setup project?

Solution

  1. Create your service . Project output is .exe. We will use Project1Service.exe as reference to project output during this text.
  2. Run command prompt
  3. You need to execute following command InstallUtil Project1Service.exe, but take care. If you have .NET 1.1 and .NET 2.0 installed on your computer you have two versions of InstallUtil as well! If you try to install service, written in .NET 2.0, with InstallUtil from .NET 1.1 you will encounter error:

    Microsoft (R) .NET Framework Installation utility Version 1.1.4322.573
    Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

    Exception occurred while initializing the installation:
    System.BadImageFormatException: The format of the file Project1Service.exe' is
    invalid..

    You need to locate correct version (try looking at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ path)

    Running this verision of the InstallUtil will produce output similar to the following:

    Microsoft (R) .NET Framework Installation utility Version 2.0.50727.42
    Copyright (c) Microsoft Corporation. All rights reserved.

    Running a transacted installation.
    :
    The Commit phase completed successfully.

    The transacted install has completed.

1 comment: