473,396 Members | 2,021 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,396 software developers and data experts.

System Service - One assembly, two services

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
Nov 16 '05 #1
6 1386
"Pawel Janik" <ja***@poczta.gazeta.pl> wrote in
news:c8**********@inews.gazeta.pl:
But there is one problem....how to make service know, what service name
should it have?


When a service is installed it is queried for its name. Its during
instalation you need to specify a different name.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/
Nov 16 '05 #2
> > But there is one problem....how to make service know, what service name
should it have?


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
Nov 16 '05 #3
"Pawel Janik" <ja***@poczta.gazeta.pl> wrote in
news:c8**********@inews.gazeta.pl:
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/
Nov 16 '05 #4
> > 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.

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/article...?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
Nov 16 '05 #5
> > > 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.

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/article...?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
Nov 16 '05 #6
"Pawel Janik" <ja***@poczta.gazeta.pl> wrote in news:c8hm0i$fbl$1
@inews.gazeta.pl:
It cou'd be a example in any .net language...it's not a problem to me...


Except the last service I built was in Win32 - so I dont think the code would
help you. :)
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/
Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Scott Reynolds | last post by:
I am having a problem exposing a class inherited from the collection base class as a webservice. If I expose the collection on a web page all works well and I am very happy. However when I try and...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
0
by: Kirk | last post by:
I'm trying to use a Web Service to be a Remoting client of an existing ..NET 2.0 server. But I get the following error when I try to use System.Runtime.Remoting.Channels.Http in my WebService. ...
2
by: Kirk | last post by:
I'm trying to use a Web Service to be a Remoting client of an existing ..NET 2.0 server. But I get the following error when I try to use System.Runtime.Remoting.Channels.Http in my WebService. ...
1
by: Mongo | last post by:
I am getting the following error when I try to run a new webservice I have placed on any one of 4 windows 2003 servers. (Running under ASP.NET 1.1) To minimize the problem, I created a simple...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.