473,395 Members | 1,613 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,395 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 2568
"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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.