467,877 Members | 1,128 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,877 developers. It's quick & easy.

Creating Install for Services

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().

Jun 27 '08 #1
  • viewed: 4979
Share:
1 Reply
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...and-heres.aspx
--
Phil Wilson

"Israel" <is**********@hotmail.comwrote in message
news:a4**********************************@79g2000h sk.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().
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by DraguVaso | last post: by
2 posts views Thread by Fan Wang | last post: by
1 post views Thread by Jon H | last post: by
9 posts views Thread by Rotzooi | last post: by
3 posts views Thread by clsmith66 | last post: by
1 post views Thread by =?Utf-8?B?Qi5BaGxzdGVkdA==?= | last post: by
4 posts views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.