From: Israel on
I found it surprisingly unintuitive and difficult to get the
installation code to work properly and I found very little help on the
google groups so I figured I’d post the things that burned me so
someone else doesn’t have to work through the same issues.

I created a service using the wizard and then I added an Installer
class. On the canvas of the installer class I plopped down an
instance of a ServiceInstaller and a ServerProcessInstaller. After I
thought I had everything set up correctly I tried running
InstallUtil.exe on my service exe.

Problem #1:
I got the following error:
System.BadImageFormatException: The format of the file
'SnapshotAnalyzer.exe' is invalid
I come to find out that somehow the .NET 1.1 was in my path BEFORE
the .NET 2.0 path (for whatever reason). I got rid of the .NET 1.1
from my path.

Problem #2:
I got the following error:
System.InvalidOperationException: Installation failed due to the
absence of a ServiceProcessInstaller. The ServiceProcessInstaller must
either be the containing installer, or it must be present in the
Installers collection on the same installer as the ServiceInstaller.
What I hadn’t realized is that the ServiceInstaller automatically had
its parent set to the Installer class but the ServiceProcessInstaller
did not so I had to manually set its parent property.

Problem #3:
I got the following error:
System.ArgumentException: Must specify value for source.
I hadn’t set the “ServiceName” on the ServiceInstaller instance. I
guess somehow I’m supposed to know that “source” and “ServiceName” are
really the same thing?

Also I found this article useful for making a service able to install/
uninstall itself without the use of installutil.exe. In addition
allow the service to run as a normal process so you can debug it:
http://www.eggheadcafe.com/articles/20060104.asp
The example is in Visual Studio 2003 but it’s easy enough to modify it
if you just add some public methods on the service class that just
call OnStart() and OnStop().

From: Phil Wilson on
Nobody who works with fully-featured installation tools uses installer
classes to install services. MSI has built-in support to do it "for free"
and pretty much all the tools *except* Visual Studio have IDE support to
populate the ServiceInstall and ServiceControl tables that have been in
Windows Installer since before .NET came along. A further irony is that the
Windows Installer team doesn't even support the managed code installer
classes used by Visual Studio to install services.
http://robmensching.com/blog/archive/2007/04/19/Managed-Code-CustomActions-no-support-on-the-way-and-heres.aspx


--
Phil Wilson

"Israel" <israeldiperi(a)hotmail.com> wrote in message
news:a417c2d4-7384-4c3e-b21e-6b96e239ceb8(a)79g2000hsk.googlegroups.com...
I found it surprisingly unintuitive and difficult to get the
installation code to work properly and I found very little help on the
google groups so I figured I�d post the things that burned me so
someone else doesn�t have to work through the same issues.

I created a service using the wizard and then I added an Installer
class. On the canvas of the installer class I plopped down an
instance of a ServiceInstaller and a ServerProcessInstaller. After I
thought I had everything set up correctly I tried running
InstallUtil.exe on my service exe.

Problem #1:
I got the following error:
System.BadImageFormatException: The format of the file
'SnapshotAnalyzer.exe' is invalid
I come to find out that somehow the .NET 1.1 was in my path BEFORE
the .NET 2.0 path (for whatever reason). I got rid of the .NET 1.1
from my path.

Problem #2:
I got the following error:
System.InvalidOperationException: Installation failed due to the
absence of a ServiceProcessInstaller. The ServiceProcessInstaller must
either be the containing installer, or it must be present in the
Installers collection on the same installer as the ServiceInstaller.
What I hadn�t realized is that the ServiceInstaller automatically had
its parent set to the Installer class but the ServiceProcessInstaller
did not so I had to manually set its parent property.

Problem #3:
I got the following error:
System.ArgumentException: Must specify value for source.
I hadn�t set the �ServiceName� on the ServiceInstaller instance. I
guess somehow I�m supposed to know that �source� and �ServiceName� are
really the same thing?

Also I found this article useful for making a service able to install/
uninstall itself without the use of installutil.exe. In addition
allow the service to run as a normal process so you can debug it:
http://www.eggheadcafe.com/articles/20060104.asp
The example is in Visual Studio 2003 but it�s easy enough to modify it
if you just add some public methods on the service class that just
call OnStart() and OnStop().