473,225 Members | 1,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

Windows Service installation problem

I'm programming quite simple Windows Service using C# 2005. I also made
setup for it into same solution.

When I run setup to install service, it's going fine into C:\Program
Files\MyCompany\My Service, and Event Log tells...

Event Type: Information
Event Source: MsiInstaller
Event Category: None
Event ID: 11707
Date: 11.6.2008
Time: 10:37:28
User: ...\...
Computer: MYCOMPUTER
Description:
Product: My Service -- Installation completed successfully.

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.

....but when I check Computer Management/Services, it is not there in
services list!
I made earlier another service same way, and it installed that service
into services list fine (but is not starting the service automatically).
When I'm comparing these services, I don't find what is wrong with this
new service intallation.

Anyway I can install this new service into services list using
C:\Program Files\MyCompany\My Service\install.bat-file containing...
@ECHO OFF
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\inst allutil /i MyService.exe

NET START MyService
PAUSE

and then the Event Log tells...

Event Type: Information
Event Source: MyService
Event Category: None
Event ID: 0
Date: 11.6.2008
Time: 10:54:44
User: N/A
Computer: MYCOMPUTER
Description:
Service started successfully.

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
Any succestions what might be wrong with my installation?
Jun 27 '08 #1
3 2563
"Mika M" <mi*********************@kolumbus.fiwrote in message
news:Ol**************@TK2MSFTNGP06.phx.gbl...
...but when I check Computer Management/Services, it is not there in
services list!
I made earlier another service same way, and it installed that service
into services list fine (but is not starting the service automatically).
When I'm comparing these services, I don't find what is wrong with this
new service intallation.
1) First, did you add a project installer to your service?
To do this in VS2005, have service1.cs (or whatever your service1.cs file
was renamed as) open in the design mode window. Right click on it and select
"Add Installer" from the context menu. This 2nd installer installs your
service into windows services when the main application setup is run.
Doing this causes file ProjectInstaller.cs file to be added to the project.
Double click that in solution explorer to show design window (if it's not
already open) and you'll see a blank page with 2 embedded controls,
serviceProcessInstaller1 and serviceInstaller1.
Set the properties for serviceInstaller1 and serviceProcessInstaller1 as you
like. (I have serviceProcessInstaller1.Account set to LocalMachine for
accessing my database and serviceInstaller1.ServiceName set to
myservice.service, set serviceInstaller1.Description to some useful text to
describe your service)
That should be enough to get your service installed in windows services.

2) To make run your service after installation...
Open the file "ProjectInstaller.cs" in design view. Select the "background"
in the designer window (not the embedded controls) and switch to the events
section of the property editor. Double click the "Committed" event to
generate an event handler in the code.
The following code works on my installation

private void ProjectInstaller_Committed(object sender, InstallEventArgs
e)
{
try
{
// Change the following to your service name. Should be
serviceInstaller1.ServiceName
string servicename = "myservice.service";
System.ServiceProcess.ServiceController[] services;
services = System.ServiceProcess.ServiceController.GetService s();
bool Found = false;
foreach (ServiceController sc in services)
if (string.Compare(servicename, sc.ServiceName, true) == 0)
Found = true;
if (Found)
{
ServiceController Controller = new ServiceController(servicename);
if (Controller.Status == ServiceControllerStatus.Stopped)
Controller.Start();
}
}
catch
{

}
}
Jun 27 '08 #2
Thanks for the reply!

My setup project was only missing "Custom Actions". That was why it
didn't install my application into services list. I noticed it by myself
at last.

That is good to know how to start service after installation! I'll try
it on monday.
--

Claire kirjoitti:
"Mika M" <mi*********************@kolumbus.fiwrote in message
news:Ol**************@TK2MSFTNGP06.phx.gbl...
>...but when I check Computer Management/Services, it is not there in
services list!
I made earlier another service same way, and it installed that service
into services list fine (but is not starting the service
automatically). When I'm comparing these services, I don't find what
is wrong with this new service intallation.

1) First, did you add a project installer to your service?
To do this in VS2005, have service1.cs (or whatever your service1.cs
file was renamed as) open in the design mode window. Right click on it
and select "Add Installer" from the context menu. This 2nd installer
installs your service into windows services when the main application
setup is run.
Doing this causes file ProjectInstaller.cs file to be added to the
project. Double click that in solution explorer to show design window
(if it's not already open) and you'll see a blank page with 2 embedded
controls, serviceProcessInstaller1 and serviceInstaller1.
Set the properties for serviceInstaller1 and serviceProcessInstaller1 as
you like. (I have serviceProcessInstaller1.Account set to LocalMachine
for accessing my database and serviceInstaller1.ServiceName set to
myservice.service, set serviceInstaller1.Description to some useful text
to describe your service)
That should be enough to get your service installed in windows services.

2) To make run your service after installation...
Open the file "ProjectInstaller.cs" in design view. Select the
"background" in the designer window (not the embedded controls) and
switch to the events section of the property editor. Double click the
"Committed" event to generate an event handler in the code.
The following code works on my installation

private void ProjectInstaller_Committed(object sender,
InstallEventArgs e)
{
try
{
// Change the following to your service name. Should be
serviceInstaller1.ServiceName
string servicename = "myservice.service";
System.ServiceProcess.ServiceController[] services;
services = System.ServiceProcess.ServiceController.GetService s();
bool Found = false;
foreach (ServiceController sc in services)
if (string.Compare(servicename, sc.ServiceName, true) == 0)
Found = true;
if (Found)
{
ServiceController Controller = new ServiceController(servicename);
if (Controller.Status == ServiceControllerStatus.Stopped)
Controller.Start();
}
}
catch
{

}
}

Jun 27 '08 #3
In my case the correct event to start the service upon installation was ProjectInstaller_AfterInstall.
The event ProjectInstaller_Committed did not start the service.
Sep 19 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: decrypted | last post by:
I want my users to be able to specify where thier configuration files are located for a windows service. Since having startup params don't seem to be a real option here I want to use the...
0
by: Theresa Smallwood | last post by:
I am having some trouble with a windows service I am trying to install. It builds just fine, but when I try to install it using an MSI created from a ..NET setup project, I get this error: ...
1
by: dparden | last post by:
I have followed the instructions for in the Walkthrough: Creating a Windows Service Application in the Component Designer. Everything compiles and builds fine, but I get an error "The account...
1
by: Al | last post by:
Hi - I have a interesting issue that I am trying to resolve with a Windows Service I created. I am trying to allow the end-user to install multiple copies of the service on the same server (think...
1
by: 1Cajun | last post by:
I have an Administration form that I would like to use to not only set some variables for the service but also install and start and stop the service. I have created an install project and can...
6
by: Jason Richmeier | last post by:
I have encountered a problem with the installation of a Windows service. I know I have done this in the past so I am at a loss as to what I might be doing wrong. When I create a setup project...
1
by: 511 | last post by:
I have written a Windows service which is consuming a webservices. When i am trying ti install the windows service using installutil.exe it gives me an errorr:- Exception occured while...
1
by: Steve Harclerode | last post by:
I have a Windows service that I wrote with Visual Studio 2008, and I would like to create a deployment file for my client. There used to be an option "Add Installer" in the properties window when...
0
by: Sai Ram | last post by:
To create windows service i took the help of this link "http://www.codeproject.com/KB/files/C__FileWatcher.aspx". By running the same file from the above link i got installation problem. Actually...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.