Peter,
Thanks for your post. Once I understood where you wanted the code to go, I
put it in and went back to your 9/15/04 posting to check to make sure I
posted everything you suggested. I am attaching my current code for the 2
procedures at the end of this post.
I run a build and place the EXE (after checking the date to make sure it is
the most current) in the C:\ directory. When I run the line
"InstallUtil.exe c:\beepservice.exe" in a command prompt window, it seems to
start installing and then I get the following lines:
-----------------------------------------------
....
An exception occurred during the Install phase.
System.ComponentModel.Win32Exception: The specified service already exists
The Rollback phase of the installation is beginning.
....
-----------------------------------------------
I check the Services list in the Admin Tools section of the Control Panel
and don't see it listed. So, I ran "InstallUtil.exe u/ c:\beepservice.exe"
anyway thinking it would clear out anything that is there and I get the
following lines in the middle of the install:
-----------------------------------------------
Warning: The soure BeepService is not registered on the local machine.
Service BeepService is being removed from the system...
An exception occurred during the uninstallation of the
System.ServiceProcess.ServiceInstallation installer.
System.CoomponentModel.Win32Exception: The specified service does not exist
as an installed service
An exception occurred while uninstalling. This exception will be ignored
and the uninstall will continue. However, the application might not be
fully uninstalled after the uninstall is complete.
-----------------------------------------------
I am working off the Billy Hollis article
(
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvsm01/ht
ml/vs0112dt.asp) which does not go into any of this detail. Is all this
necessary/caused because my workstation is XP? I will also email Mr. Hollis
and see if he has any ideas on this. Are there any KB articles that have
"how-tos" or sample/demo code on installing a windows service? I have to
get this done and am running low on time.
Thank you for all your help.... Schoo
PS> Here is my code:
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.ServiceProcessInstaller1 = New
System.ServiceProcess.ServiceProcessInstaller
Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller
'
'ServiceProcessInstaller1
'
Me.ServiceProcessInstaller1.Password = "<my password>"
Me.ServiceProcessInstaller1.Username = "USV3270JFS-9\sschum"
'system.Configuration.Install.InstallEventHandler(me.serviceprocessinstaller
1_After
'ServiceInstaller1
'
Me.ServiceInstaller1.ServiceName = "BeepService"
'me.Installers.AddRange(new System.Configuration.Install.Installer()
'
'ProjectInstaller
'
Me.Installers.AddRange(New System.Configuration.Install.Installer()
{Me.ServiceProcessInstaller1, Me.ServiceInstaller1})
End Sub
#End Region
Private Sub ServiceProcessInstaller1_AfterInstall(ByVal sender As
Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles
ServiceProcessInstaller1.AfterInstall
Me.ServiceInstaller1.ServiceName = "BeepService"
End Sub
Private Sub ServiceInstaller1_AfterInstall(ByVal sender As Object, ByVal
e As System.Configuration.Install.InstallEventArgs) Handles
ServiceInstaller1.AfterInstall
Me.Installers.AddRange(New System.Configuration.Install.Installer()
{Me.ServiceProcessInstaller1, Me.ServiceInstaller1})
End Sub