By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,281 Members | 2,201 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,281 IT Pros & Developers. It's quick & easy.

C# service installer

P: n/a
Could not find ansewr:

in ProjectInstaller, RunInstallerAttribute[]:
.....
this.serviceInstaller1.ServiceName = MyServiceName;

in the code:
public class MyService : System.ServiceProcess.ServiceBase
{
string MyServiceName = "configSendmailA";

....
private void InitializeComponent()
{
this.ServiceName = MyServiceName;

So I have MyServiceName as constant in both and fix,
process runs etc... OK

But! how to make MyServiceName dynamic - means: set durring
installUtill run?

KK
Jul 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
You could try inserting some code that pops some UI to ask the user for
that info...
---
David Guyer - VBQA Deployment Testing
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "krisk" <kk@easylink.com>
Sender: "krisk" <kk@easylink.com>
Subject: C# service installer
Date: Wed, 10 Sep 2003 09:15:57 -0700
Lines: 23
Message-ID: <0b****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN3ttEqyny5X+gWSfylTq0zFri43A==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:107976
NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
X-Tomcat-NG: microsoft.public.dotnet.general

Could not find ansewr:

in ProjectInstaller, RunInstallerAttribute[]:
....
this.serviceInstaller1.ServiceName = MyServiceName;

in the code:
public class MyService : System.ServiceProcess.ServiceBase
{
string MyServiceName = "configSendmailA";

...
private void InitializeComponent()
{
this.ServiceName = MyServiceName;

So I have MyServiceName as constant in both and fix,
process runs etc... OK

But! how to make MyServiceName dynamic - means: set durring
installUtill run?

KK


Jul 21 '05 #2

P: n/a
Thank you,

but how ?
Does
public class MyService : System.ServiceProcess.ServiceBase
MyServiceName has anything to do with

[RunInstallerAttribute(true)]
public class ProjectInstaller :
System.Configuration.Install.Installer
{
private string MyServiceName = "...";

anything to do with each other but the value has to be the
same. I mean if I pup up UI in Installer, shouldn't I also
pop-up UI in the Service module? Real question is how to
communicate between ProjectInstaller variable and MySrvice
module variable? Can I do it at all? and which is called
first: MyService.Main or ProjectInstaller

thank you

KK
-----Original Message-----
You could try inserting some code that pops some UI to ask the user forthat info...
---
David Guyer - VBQA Deployment Testing
This posting is provided "AS IS" with no warranties, and confers no rights.--------------------
Content-Class: urn:content-classes:message
From: "krisk" <kk@easylink.com>
Sender: "krisk" <kk@easylink.com>
Subject: C# service installer
Date: Wed, 10 Sep 2003 09:15:57 -0700
Lines: 23
Message-ID: <0b****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN3ttEqyny5X+gWSfylTq0zFri43A==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:107976NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
X-Tomcat-NG: microsoft.public.dotnet.general

Could not find ansewr:

in ProjectInstaller, RunInstallerAttribute[]:
....
this.serviceInstaller1.ServiceName = MyServiceName;

in the code:
public class MyService : System.ServiceProcess.ServiceBase {
string MyServiceName = "configSendmailA";

...
private void InitializeComponent()
{
this.ServiceName = MyServiceName;

So I have MyServiceName as constant in both and fix,
process runs etc... OK

But! how to make MyServiceName dynamic - means: set durringinstallUtill run?

KK


.

Jul 21 '05 #3

P: n/a
Okay, I've taken a closer look, and I think I understand the scenario a bit
better!

The values don't have to be the same, most of the time. The one used in
the ServiceInstaller is the one that will eventually be displayed and be
the official name. If your service doesn't read or use the "ServiceName"
property on the ServiceBase class, then you don't need them to be the same.

If you modify them using the installer class, you'll need to Add the
ServiceName value to the stateSaver in the overridden Install method, and
then load it from the savedState object in Rollback and UnInstall methods.
This way, when you uninstall, it will try to uninstall using the correct
service name it was given during install. If you don't do that, your
uninstall will fail, and you'll be blocked from removing it from your
machine. (Ask me how I know this! :-) )

If you do need to use the ServiceName in your service code, then you'll
probalby want to make the ServiceName a dynamic property by following the
steps below, and then modifying the app.config during install time. See
the following whitepaper for an example of how to do that:
http://msdn.microsoft.com/library/de...us/vsintro7/ht
ml/vxwlkwalkthroughpassingdatatocustomaction.asp

Make the service name dynamic so that it reads it from the app.config file.

selecting your Service.cs file, then it's designer, and going to the
property grid.
then, expand the (DynamicProperties) property, and select (Advanced)
then, click the ... button and in the dialog that pops up
Check ServiceName

---
David Guyer - VBQA Deployment Testing
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "KrisK" <kk@easylink.com>
Sender: "KrisK" <kk@easylink.com>
References: <0b****************************@phx.gbl> <6x*************@cpmsftngxa06.phx.gbl>Subject: RE: C# service installer
Date: Wed, 10 Sep 2003 12:44:57 -0700
Lines: 87
Message-ID: <04****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN31APKW+LkX3ocRR2RCcUPGhgYOA==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:108018
NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
X-Tomcat-NG: microsoft.public.dotnet.general

Thank you,

but how ?
Does
public class MyService : System.ServiceProcess.ServiceBase
MyServiceName has anything to do with

[RunInstallerAttribute(true)]
public class ProjectInstaller :
System.Configuration.Install.Installer
{
private string MyServiceName = "...";

anything to do with each other but the value has to be the
same. I mean if I pup up UI in Installer, shouldn't I also
pop-up UI in the Service module? Real question is how to
communicate between ProjectInstaller variable and MySrvice
module variable? Can I do it at all? and which is called
first: MyService.Main or ProjectInstaller

thank you

KK
-----Original Message-----
You could try inserting some code that pops some UI to

ask the user for
that info...
---
David Guyer - VBQA Deployment Testing
This posting is provided "AS IS" with no warranties, and

confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "krisk" <kk@easylink.com>
Sender: "krisk" <kk@easylink.com>
Subject: C# service installer
Date: Wed, 10 Sep 2003 09:15:57 -0700
Lines: 23
Message-ID: <0b****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN3ttEqyny5X+gWSfylTq0zFri43A==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gblmicrosoft.public.dotnet.general:107976NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
X-Tomcat-NG: microsoft.public.dotnet.general

Could not find ansewr:

in ProjectInstaller, RunInstallerAttribute[]:
....
this.serviceInstaller1.ServiceName = MyServiceName;

in the code:
public class MyService :System.ServiceProcess.ServiceBase {
string MyServiceName = "configSendmailA";

...
private void InitializeComponent()
{
this.ServiceName = MyServiceName;

So I have MyServiceName as constant in both and fix,
process runs etc... OK

But! how to make MyServiceName dynamic - means: setdurringinstallUtill run?

KK


.


Jul 21 '05 #4

P: n/a
David,

thank you very much for help. I will be looking into your
solution.

My solution is simple: I user DOS enviromntal var to read
it in and set ServiceName in both places, if I want to run
the same exe as two services on the same machine.

On the side note:
Am i correct that there is no way to set
:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\mySer
vice]
;"Description"="description of my service"

in the installer code?

Thanks again
KK

-----Original Message-----
Okay, I've taken a closer look, and I think I understand the scenario a bitbetter!

The values don't have to be the same, most of the time. The one used inthe ServiceInstaller is the one that will eventually be displayed and bethe official name. If your service doesn't read or use the "ServiceName"property on the ServiceBase class, then you don't need them to be the same.
If you modify them using the installer class, you'll need to Add theServiceName value to the stateSaver in the overridden Install method, andthen load it from the savedState object in Rollback and UnInstall methods.This way, when you uninstall, it will try to uninstall using the correctservice name it was given during install. If you don't do that, youruninstall will fail, and you'll be blocked from removing it from yourmachine. (Ask me how I know this! :-) )

If you do need to use the ServiceName in your service code, then you'llprobalby want to make the ServiceName a dynamic property by following thesteps below, and then modifying the app.config during install time. Seethe following whitepaper for an example of how to do that:http://msdn.microsoft.com/library/default.asp? url=/library/en-us/vsintro7/html/vxwlkwalkthroughpassingdatatocustomaction.asp

Make the service name dynamic so that it reads it from the app.config file.
selecting your Service.cs file, then it's designer, and going to theproperty grid.
then, expand the (DynamicProperties) property, and select (Advanced) then, click the ... button and in the dialog that pops up Check ServiceName

---
David Guyer - VBQA Deployment Testing
This posting is provided "AS IS" with no warranties, and confers no rights.--------------------
Content-Class: urn:content-classes:message
From: "KrisK" <kk@easylink.com>
Sender: "KrisK" <kk@easylink.com>
References: <0b****************************@phx.gbl>

<6x*************@cpmsftngxa06.phx.gbl>
Subject: RE: C# service installer
Date: Wed, 10 Sep 2003 12:44:57 -0700
Lines: 87
Message-ID: <04****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN31APKW+LkX3ocRR2RCcUPGhgYOA==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:108018NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
X-Tomcat-NG: microsoft.public.dotnet.general

Thank you,

but how ?
Does
public class MyService : System.ServiceProcess.ServiceBaseMyServiceName has anything to do with

[RunInstallerAttribute(true)]
public class ProjectInstaller :
System.Configuration.Install.Installer
{
private string MyServiceName = "...";

anything to do with each other but the value has to be thesame. I mean if I pup up UI in Installer, shouldn't I alsopop-up UI in the Service module? Real question is how to
communicate between ProjectInstaller variable and MySrvicemodule variable? Can I do it at all? and which is called
first: MyService.Main or ProjectInstaller

thank you

KK
-----Original Message-----
You could try inserting some code that pops some UI to

ask the user for
that info...
---
David Guyer - VBQA Deployment Testing
This posting is provided "AS IS" with no warranties, and
confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "krisk" <kk@easylink.com>
Sender: "krisk" <kk@easylink.com>
Subject: C# service installer
Date: Wed, 10 Sep 2003 09:15:57 -0700
Lines: 23
Message-ID: <0b****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE

V5.50.4910.0300Thread-Index: AcN3ttEqyny5X+gWSfylTq0zFri43A==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl

microsoft.public.dotnet.general:107976
NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
X-Tomcat-NG: microsoft.public.dotnet.general

Could not find ansewr:

in ProjectInstaller, RunInstallerAttribute[]:
....
this.serviceInstaller1.ServiceName = MyServiceName;

in the code:
public class MyService :

System.ServiceProcess.ServiceBase
{
string MyServiceName = "configSendmailA";

...
private void InitializeComponent()
{
this.ServiceName = MyServiceName;

So I have MyServiceName as constant in both and fix,
process runs etc... OK

But! how to make MyServiceName dynamic - means: set

durring
installUtill run?

KK
.


.

Jul 21 '05 #5

P: n/a
Other than having a custom action which sets the appropriate registry key,
then the answer is no, unfortunately.

Todd

Todd Apley Visual Basic Deployment Test Team
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| >Content-Class: urn:content-classes:message
| >From: "KrisK" <kk@easylink.com>
| >Sender: "KrisK" <kk@easylink.com>
| >References: <0b****************************@phx.gbl>
<6x*************@cpmsftngxa06.phx.gbl>
<04****************************@phx.gbl>
<cW**************@cpmsftngxa06.phx.gbl>
| >Subject: RE: C# service installer
| >Date: Mon, 15 Sep 2003 09:12:45 -0700
| >Lines: 201
| >Message-ID: <09****************************@phx.gbl>
| >MIME-Version: 1.0
| >Content-Type: text/plain;
| > charset="iso-8859-1"
| >Content-Transfer-Encoding: 7bit
| >X-Newsreader: Microsoft CDO for Windows 2000
| >X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >Thread-Index: AcN7pDMiz7mhv/vOTzSfRCAxWY4ygQ==
| >Newsgroups: microsoft.public.dotnet.general
| >Path: cpmsftngxa07.phx.gbl
| >Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.general:108254
| >NNTP-Posting-Host: tk2msftngxa08.phx.gbl 10.40.1.160
| >X-Tomcat-NG: microsoft.public.dotnet.general
| >
| >David,
| >
| >thank you very much for help. I will be looking into your
| >solution.
| >
| >My solution is simple: I user DOS enviromntal var to read
| >it in and set ServiceName in both places, if I want to run
| >the same exe as two services on the same machine.
| >
| >On the side note:
| >Am i correct that there is no way to set
| >:
| >[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\mySer
| >vice]
| >;"Description"="description of my service"
| >
| >in the installer code?
| >
| >Thanks again
| >KK
| >
| >
| >>-----Original Message-----
| >>Okay, I've taken a closer look, and I think I understand
| >the scenario a bit
| >>better!
| >>
| >>The values don't have to be the same, most of the time.
| >The one used in
| >>the ServiceInstaller is the one that will eventually be
| >displayed and be
| >>the official name. If your service doesn't read or use
| >the "ServiceName"
| >>property on the ServiceBase class, then you don't need
| >them to be the same.
| >>
| >>If you modify them using the installer class, you'll need
| >to Add the
| >>ServiceName value to the stateSaver in the overridden
| >Install method, and
| >>then load it from the savedState object in Rollback and
| >UnInstall methods.
| >>This way, when you uninstall, it will try to uninstall
| >using the correct
| >>service name it was given during install. If you don't do
| >that, your
| >>uninstall will fail, and you'll be blocked from removing
| >it from your
| >>machine. (Ask me how I know this! :-) )
| >>
| >>If you do need to use the ServiceName in your service
| >code, then you'll
| >>probalby want to make the ServiceName a dynamic property
| >by following the
| >>steps below, and then modifying the app.config during
| >install time. See
| >>the following whitepaper for an example of how to do
| >that:
| >>http://msdn.microsoft.com/library/default.asp?
| >url=/library/en-us/vsintro7/ht
| >>ml/vxwlkwalkthroughpassingdatatocustomaction.asp
| >>
| >>Make the service name dynamic so that it reads it from
| >the app.config file.
| >>
| >> selecting your Service.cs file, then it's designer, and
| >going to the
| >>property grid.
| >> then, expand the (DynamicProperties) property, and
| >select (Advanced)
| >> then, click the ... button and in the dialog that pops
| >up
| >> Check ServiceName
| >>
| >>
| >>
| >>---
| >>David Guyer - VBQA Deployment Testing
| >>This posting is provided "AS IS" with no warranties, and
| >confers no rights.
| >>--------------------
| >>>Content-Class: urn:content-classes:message
| >>>From: "KrisK" <kk@easylink.com>
| >>>Sender: "KrisK" <kk@easylink.com>
| >>>References: <0b****************************@phx.gbl>
| >><6x*************@cpmsftngxa06.phx.gbl>
| >>>Subject: RE: C# service installer
| >>>Date: Wed, 10 Sep 2003 12:44:57 -0700
| >>>Lines: 87
| >>>Message-ID: <04****************************@phx.gbl>
| >>>MIME-Version: 1.0
| >>>Content-Type: text/plain;
| >>> charset="iso-8859-1"
| >>>Content-Transfer-Encoding: 7bit
| >>>X-Newsreader: Microsoft CDO for Windows 2000
| >>>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >>>Thread-Index: AcN31APKW+LkX3ocRR2RCcUPGhgYOA==
| >>>Newsgroups: microsoft.public.dotnet.general
| >>>Path: cpmsftngxa06.phx.gbl
| >>>Xref: cpmsftngxa06.phx.gbl
| >microsoft.public.dotnet.general:108018
| >>>NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| >>>X-Tomcat-NG: microsoft.public.dotnet.general
| >>>
| >>>Thank you,
| >>>
| >>>but how ?
| >>>Does
| >>>public class MyService :
| >System.ServiceProcess.ServiceBase
| >>>MyServiceName has anything to do with
| >>>
| >>>[RunInstallerAttribute(true)]
| >>>public class ProjectInstaller :
| >>>System.Configuration.Install.Installer
| >>> {
| >>> private string MyServiceName = "...";
| >>>
| >>>anything to do with each other but the value has to be
| >the
| >>>same. I mean if I pup up UI in Installer, shouldn't I
| >also
| >>>pop-up UI in the Service module? Real question is how to
| >>>communicate between ProjectInstaller variable and
| >MySrvice
| >>>module variable? Can I do it at all? and which is called
| >>>first: MyService.Main or ProjectInstaller
| >>>
| >>>thank you
| >>>
| >>>KK
| >>>
| >>>
| >>>
| >>>>-----Original Message-----
| >>>>You could try inserting some code that pops some UI to
| >>>ask the user for
| >>>>that info...
| >>>>
| >>>>
| >>>>---
| >>>>David Guyer - VBQA Deployment Testing
| >>>>This posting is provided "AS IS" with no warranties,
| >and
| >>>confers no rights.
| >>>>--------------------
| >>>>>Content-Class: urn:content-classes:message
| >>>>>From: "krisk" <kk@easylink.com>
| >>>>>Sender: "krisk" <kk@easylink.com>
| >>>>>Subject: C# service installer
| >>>>>Date: Wed, 10 Sep 2003 09:15:57 -0700
| >>>>>Lines: 23
| >>>>>Message-ID: <0b****************************@phx.gbl>
| >>>>>MIME-Version: 1.0
| >>>>>Content-Type: text/plain;
| >>>>> charset="iso-8859-1"
| >>>>>Content-Transfer-Encoding: 7bit
| >>>>>X-Newsreader: Microsoft CDO for Windows 2000
| >>>>>X-MimeOLE: Produced By Microsoft MimeOLE
| >V5.50.4910.0300
| >>>>>Thread-Index: AcN3ttEqyny5X+gWSfylTq0zFri43A==
| >>>>>Newsgroups: microsoft.public.dotnet.general
| >>>>>Path: cpmsftngxa06.phx.gbl
| >>>>>Xref: cpmsftngxa06.phx.gbl
| >>>microsoft.public.dotnet.general:107976
| >>>>>NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| >>>>>X-Tomcat-NG: microsoft.public.dotnet.general
| >>>>>
| >>>>>Could not find ansewr:
| >>>>>
| >>>>>in ProjectInstaller, RunInstallerAttribute[]:
| >>>>>....
| >>>>>this.serviceInstaller1.ServiceName = MyServiceName;
| >>>>>
| >>>>>in the code:
| >>>>>public class MyService :
| >>>System.ServiceProcess.ServiceBase
| >>>>> {
| >>>>> string MyServiceName = "configSendmailA";
| >>>>>
| >>>>>...
| >>>>> private void InitializeComponent()
| >>>>> {
| >>>>> this.ServiceName = MyServiceName;
| >>>>>
| >>>>>So I have MyServiceName as constant in both and fix,
| >>>>>process runs etc... OK
| >>>>>
| >>>>>But! how to make MyServiceName dynamic - means: set
| >>>durring
| >>>>>installUtill run?
| >>>>>
| >>>>>KK
| >>>>>
| >>>>
| >>>>.
| >>>>
| >>>
| >>
| >>.
| >>
| >

Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.