System Service - One assembly, two services

P

Pawel Janik

Hello,

I wrote a system service, whis is located in assembly called "s1.exe". But i
like to install this service twice. Problem starts, when service starts....a
service code loks like this:

public class TestService : ServiceBase
{
public TestService(string serviceName)
{
this.ServiceName = "????";
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}

ServiceThread serviceClass;

protected override void OnStart(string[] args)
{
serviceClass = new ServiceThread(param);
}

protected override void OnStop()
{
if(serviceClass!=null)
serviceClass.Stop();
serviceClass = null;
}

public static void Main(string[] Args)
{
System.ServiceProcess.ServiceBase.Run(new
System.ServiceProcess.ServiceBase[] {new TestService(param)});
}
}

But there is one problem....how to make service know, what service name
should it have?
I've tried to use command line arguments, but i'm not unable to to pass this
(except the situation, when i start service manually...)

regards,
Pawel Janik
 
P

Pawel Janik

But there is one problem....how to make service know, what service name
When a service is installed it is queried for its name. Its during
instalation you need to specify a different name.
Yes, you have right, so i was able to install it twice.

In previous post i pasted a system service code, that is not executed during
installation, but while starting service...and in this place i also need a
service name!
Or i am wrong? coud you point me to a very simple example of a service
class?

regards,
Pawel Janik
 
C

Chad Z. Hower aka Kudzu

Pawel Janik said:
In previous post i pasted a system service code, that is not executed
during installation, but while starting service...and in this place i
also need a service name!

You cannot specify it at start up. You have to specify it at installation -
it goes into the registry. Each services supports -install, and thats when
you specify it.
Or i am wrong? coud you point me to a very simple example of a service
class?

I've not done it in C#, so I dont have code handy that would be of use to
you.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
 
P

Pawel Janik

In previous post i pasted a system service code, that is not executed
You cannot specify it at start up. You have to specify it at installation -
it goes into the registry. Each services supports -install, and thats when
you specify it.


I've not done it in C#, so I dont have code handy that would be of use to
you.
It cou'd be a example in any .net language...it's not a problem to me...

but i'm still quite sure, that you have to put a service name while
starting...lets se an example:
http://www.theserverside.net/articles/showarticle.tss?id=Automation

Ant there, in system service code, stands a line:
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me.ServiceName = "FTPWatch" '(1c)Change to FTPwatch Here
End Sub

ommiting this line goes to troubles while starting service.....

regards,
Pawel Janik
 
P

Pawel Janik

In previous post i pasted a system service code, that is not executed
It cou'd be a example in any .net language...it's not a problem to me...

but i'm still quite sure, that you have to put a service name while
starting...lets se an example:
http://www.theserverside.net/articles/showarticle.tss?id=Automation

Ant there, in system service code, stands a line:
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me.ServiceName = "FTPWatch" '(1c)Change to FTPwatch Here
End Sub

ommiting this line goes to troubles while starting service.....
sorry....my mistake....
i did not try setting service name...it works....;)

but there i have another problem...how to get my service name? ;)..a
ServiceBase.ServiceName property is empty :(

regards,
Pawel Janik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top