Answered by:
Installing Windows Service

Question
-
Hi,
I am newbie in .NET 2005. I have created a Windows Service program. Now I want to create a Visual Studio Setup wizard. This is what I did:
1) Go to New Project->Other Project Type->Setup & Deployment->Setup Wizard
2) In my Application Folder, I added the exe of my Windows Service, and then just build the solution.
3) Then I run the setup executable.
I found that the windows service is not registered to my services list (I thought it will appear on Control Panel-> Administration Tools->Services ?)
What is wrong? Did I miss anything?
Please advice. I promise to grade you. Urgent. Thanks
Friday, September 15, 2006 8:25 AM
Answers
-
You need to add an installer to your service project (right click your service in design mode and select Add Installer). It will actually add two installers (one for the process and one for your service). This will then allow you to run installutil to install your service.
In your setup project add the project output from the service project to the application folder for the project. Add a custom action to your setup project (use the root Custom Actions node to add it so that it propogates to each installation stage). Select the project output from the application folder.
Build and run the setup program and it'll automatically use the installers to install and uninstall your service.
Michael Taylor - 9/15/06
Friday, September 15, 2006 2:50 PM
All replies
-
Hi,
I am newbie in .NET 2005. I have created a Windows Service program. Now I want to create a Visual Studio Setup wizard. This is what I did:
1) Go to New Project->Other Project Type->Setup & Deployment->Setup Wizard
2) In my Application Folder, I added the exe of my Windows Service, and then just build the solution.
3) Then I run the setup executable.
I found that the windows service is not registered to my services list (I thought it will appear on Control Panel-> Administration Tools->Services ?)
What is wrong? Did I miss anything?
Please advice. I promise to grade you. Urgent. Thanks
Friday, September 15, 2006 9:10 AM -
Friday, September 15, 2006 1:43 PM
-
You need to add an installer to your service project (right click your service in design mode and select Add Installer). It will actually add two installers (one for the process and one for your service). This will then allow you to run installutil to install your service.
In your setup project add the project output from the service project to the application folder for the project. Add a custom action to your setup project (use the root Custom Actions node to add it so that it propogates to each installation stage). Select the project output from the application folder.
Build and run the setup program and it'll automatically use the installers to install and uninstall your service.
Michael Taylor - 9/15/06
Friday, September 15, 2006 2:50 PM -
please do not duplicate post:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=728995&SiteID=1
I will now merge the threads
Friday, September 15, 2006 4:32 PM -
Hi Taylor,
Thanks for your explanation. I think I have already added the installer object into my service project. Now I am not able to find the "Custom Actions node" as you mentioned in my Setup Project. I did see a "Add Special Folder->Custom folder" by right-click the File System on Target Machine icon. Did you mean that one?
What I did now is adding the Primary output from my Service project to the Application Folder and the build. Then I run the executable file (.msi). After that, I only saw the executable file of my Service Project is copied into the installed folder but the service is not registered in the services list in my Administration tools.
Below is the code of my ProjectInstaller.cs. Please kindly help. I believe I'm almost there. Thanks alot.
using
System;using
System.Collections;using
System.ComponentModel;using
System.Configuration.Install;namespace
Service{
/// <summary> /// Summary description for ProjectInstaller. /// </summary>[
RunInstaller(true)] public class ProjectInstaller : System.Configuration.Install.Installer{
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1; private System.ServiceProcess.ServiceInstaller serviceInstaller1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public ProjectInstaller(){
// This call is required by the Designer.InitializeComponent();
// TODO: Add any initialization after the InitComponent call}
#region
Component Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent(){
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller(); this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller(); // // serviceProcessInstaller1 // this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem; this.serviceProcessInstaller1.Password = null; this.serviceProcessInstaller1.Username = null; // // serviceInstaller1 // this.serviceInstaller1.Description = "my Application"; this.serviceInstaller1.DisplayName = "my Application"; this.serviceInstaller1.ServiceName = "my application"; this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic; // // ProjectInstaller // this.Installers.AddRange(new System.Configuration.Install.Installer[] { this.serviceProcessInstaller1, this.serviceInstaller1});}
#endregion
}
}
Saturday, September 16, 2006 4:51 AM -
Yo, I found the answer myself. Go View->Editor to bring out the Custom Action. ThanksSaturday, September 16, 2006 5:17 AM
-
Hi guys,
Now I have got the installation of windows service done. Next, I found that the Windows Service was in "Automatic" state in the Services list once after it was installed. I need to restart the PC or manually set it to make it in "Start" state.
What can I do in my Setup project or my Service Project so that after the installation, it is automatically set to "Start" state??
This is crucial. Please help. Thanks
- Proposed as answer by T srikanth reddy Monday, February 7, 2011 6:05 AM
Saturday, September 16, 2006 6:35 AM -
hi can u please help how to create anew service from .net
Monday, February 7, 2011 6:03 AM