Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Creating Install for Services

Reply
 
Old 05-30-2008   #1 (permalink)
Israel


 
 

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


My System SpecsSystem Spec
Old 05-31-2008   #2 (permalink)
Phil Wilson


 
 

Re: Creating Install for Services

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" <israeldiperi@xxxxxx> wrote in message
news:a417c2d4-7384-4c3e-b21e-6b96e239ceb8@xxxxxx
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().


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
New Vista 64 Install - Services to Turn Off? Vista installation & setup
Sharepoint Services and Vista Install Vista installation & setup
Creating Install Cd Vista installation & setup
Creating Vista Install Disk Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46