C# service installer

  • Thread starter Thread starter krisk
  • Start date Start date
K

krisk

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
 
You could try inserting some code that pops some UI to ask the user for
that info...
 
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" <[email protected]>
Sender: "krisk" <[email protected]>
Subject: C# service installer
Date: Wed, 10 Sep 2003 09:15:57 -0700
Lines: 23
Message-ID: <[email protected]>
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

.
 
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" <[email protected]>
Sender: "KrisK" <[email protected]>
References: <[email protected]>
Subject: RE: C# service installer
Date: Wed, 10 Sep 2003 12:44:57 -0700
Lines: 87
Message-ID: <[email protected]>
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" <[email protected]>
Sender: "krisk" <[email protected]>
Subject: C# service installer
Date: Wed, 10 Sep 2003 09:15:57 -0700
Lines: 23
Message-ID: <[email protected]>
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

.
 
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\Services\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:
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" <[email protected]>
Sender: "KrisK" <[email protected]>
References: <[email protected]>
Subject: RE: C# service installer
Date: Wed, 10 Sep 2003 12:44:57 -0700
Lines: 87
Message-ID: <[email protected]>
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...
and
confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "krisk" <[email protected]>
Sender: "krisk" <[email protected]>
Subject: C# service installer
Date: Wed, 10 Sep 2003 09:15:57 -0700
Lines: 23
Message-ID: <[email protected]>
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


.

.
 
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" <[email protected]>
| >Sender: "KrisK" <[email protected]>
| >References: <[email protected]>
<6xh29#[email protected]>
<[email protected]>
<[email protected]>
| >Subject: RE: C# service installer
| >Date: Mon, 15 Sep 2003 09:12:45 -0700
| >Lines: 201
| >Message-ID: <[email protected]>
| >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\Services\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" <[email protected]>
| >>>Sender: "KrisK" <[email protected]>
| >>>References: <[email protected]>
| >><6xh29#[email protected]>
| >>>Subject: RE: C# service installer
| >>>Date: Wed, 10 Sep 2003 12:44:57 -0700
| >>>Lines: 87
| >>>Message-ID: <[email protected]>
| >>>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" <[email protected]>
| >>>>>Sender: "krisk" <[email protected]>
| >>>>>Subject: C# service installer
| >>>>>Date: Wed, 10 Sep 2003 09:15:57 -0700
| >>>>>Lines: 23
| >>>>>Message-ID: <[email protected]>
| >>>>>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
| >>>>>
| >>>>
| >>>>.
| >>>>
| >>>
| >>
| >>.
| >>
| >
 
Back
Top