[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Service install problem...

Lloyd Dupont

1/21/2003 12:40:00 AM

Hi,

I'm trying to create and install a basic service (my firt service ! .cs...)
Well it compile and install successfully but it doesn't appear in the
service windows.. so I'm unable to start / stop it!
do you have any idea ?

I use the following command to compile & install:
> csc /nologo /out:myservice.exe MyService.cs
> InstallUtil myservice.exe

and the code is:
// ---------- MyService.cs ----------------
using System;
using System.Diagnostics;
using System.IO;
using System.ServiceProcess;
using System.Threading;

// csc /nologo /out:myservice.exe MyService.cs
// InstallUtil myservice.exe
public class MyService : ServiceBase
{
public static void Main()
{
Run(new MyService());
}
StreamWriter outw;
Thread looping;
public MyService()
{
ServiceName = "MyService";
CanStop = true;
CanPauseAndContinue = false;
AutoLog = true;
try { outw = new StreamWriter(new FileStream("toto.log",
FileMode.Create)); }
catch {}
}
protected override void OnStart(string[] args)
{
looping = new Thread(new ThreadStart(loop));
looping.Start();
}
public void loop()
{
while(true) {
try { outw.WriteLine(DateTime.Now); }
catch {}
Thread.Sleep(1000);
}
}
protected override void OnStop()
{
looping.Abort();
looping = null;
}
}




6 Answers

Greg Low

1/21/2003 1:18:00 AM

0

You need to create an "installer". While you have the "design" view of the
service open in VS.NET, you should see an option to create an installer
under the properties window.

HTH

Greg Low
Brisbane, Oztralia

"Lloyd Dupont" <lloyd@galador.net> wrote in message
news:ektDizNwCHA.2668@TK2MSFTNGP09...
> Hi,
>
> I'm trying to create and install a basic service (my firt service !
.cs...)
> Well it compile and install successfully but it doesn't appear in the
> service windows.. so I'm unable to start / stop it!
> do you have any idea ?
>
> I use the following command to compile & install:
> > csc /nologo /out:myservice.exe MyService.cs
> > InstallUtil myservice.exe
>
> and the code is:
> // ---------- MyService.cs ----------------
> using System;
> using System.Diagnostics;
> using System.IO;
> using System.ServiceProcess;
> using System.Threading;
>
> // csc /nologo /out:myservice.exe MyService.cs
> // InstallUtil myservice.exe
> public class MyService : ServiceBase
> {
> public static void Main()
> {
> Run(new MyService());
> }
> StreamWriter outw;
> Thread looping;
> public MyService()
> {
> ServiceName = "MyService";
> CanStop = true;
> CanPauseAndContinue = false;
> AutoLog = true;
> try { outw = new StreamWriter(new FileStream("toto.log",
> FileMode.Create)); }
> catch {}
> }
> protected override void OnStart(string[] args)
> {
> looping = new Thread(new ThreadStart(loop));
> looping.Start();
> }
> public void loop()
> {
> while(true) {
> try { outw.WriteLine(DateTime.Now); }
> catch {}
> Thread.Sleep(1000);
> }
> }
> protected override void OnStop()
> {
> looping.Abort();
> looping = null;
> }
> }
>
>
>
>


Ryan Trudelle-Schwarz

1/21/2003 1:26:00 AM

0

"Lloyd Dupont" <lloyd@galador.net> wrote
>
> I'm trying to create and install a basic service (my firt service !
.cs...)
> Well it compile and install successfully but it doesn't appear in the
> service windows.. so I'm unable to start / stop it!
> do you have any idea ?
>
> I use the following command to compile & install:
> > csc /nologo /out:myservice.exe MyService.cs
> > InstallUtil myservice.exe

You make sure to close and reopen the services mmc? It only queries for
services when it loads. Had me worried on my first service ;)


Lloyd Dupont

1/21/2003 1:38:00 AM

0

mmhh..
what if I don't have VS.NET ?

"Greg Low" <greglow@lowell.com.au> wrote in message
news:uhEJoKOwCHA.2528@TK2MSFTNGP09...
> You need to create an "installer". While you have the "design" view of the
> service open in VS.NET, you should see an option to create an installer
> under the properties window.
>
> HTH
>
> Greg Low
> Brisbane, Oztralia
>
> "Lloyd Dupont" <lloyd@galador.net> wrote in message
> news:ektDizNwCHA.2668@TK2MSFTNGP09...
> > Hi,
> >
> > I'm trying to create and install a basic service (my firt service !
> .cs...)
> > Well it compile and install successfully but it doesn't appear in the
> > service windows.. so I'm unable to start / stop it!
> > do you have any idea ?
> >
> > I use the following command to compile & install:
> > > csc /nologo /out:myservice.exe MyService.cs
> > > InstallUtil myservice.exe
> >
> > and the code is:
> > // ---------- MyService.cs ----------------
> > using System;
> > using System.Diagnostics;
> > using System.IO;
> > using System.ServiceProcess;
> > using System.Threading;
> >
> > // csc /nologo /out:myservice.exe MyService.cs
> > // InstallUtil myservice.exe
> > public class MyService : ServiceBase
> > {
> > public static void Main()
> > {
> > Run(new MyService());
> > }
> > StreamWriter outw;
> > Thread looping;
> > public MyService()
> > {
> > ServiceName = "MyService";
> > CanStop = true;
> > CanPauseAndContinue = false;
> > AutoLog = true;
> > try { outw = new StreamWriter(new FileStream("toto.log",
> > FileMode.Create)); }
> > catch {}
> > }
> > protected override void OnStart(string[] args)
> > {
> > looping = new Thread(new ThreadStart(loop));
> > looping.Start();
> > }
> > public void loop()
> > {
> > while(true) {
> > try { outw.WriteLine(DateTime.Now); }
> > catch {}
> > Thread.Sleep(1000);
> > }
> > }
> > protected override void OnStop()
> > {
> > looping.Abort();
> > looping = null;
> > }
> > }
> >
> >
> >
> >
>
>


Lloyd Dupont

1/21/2003 1:44:00 AM

0

The mmc service ?
I see the mmc.exe in the TaskManager but I have no idea which service it is
in the Service panel, as they have plain english name there. Nor I could
find a M... M... C.... something service.

I just wonder, to know about my services state is it correct to do
Start menu->Setting->Control Panel->Administratiev tools->Services ?



"Ryan Trudelle-Schwarz" <ryan.mvp@mamanze.com> wrote in message
news:#bCXSOOwCHA.456@TK2MSFTNGP09...
> "Lloyd Dupont" <lloyd@galador.net> wrote
> >
> > I'm trying to create and install a basic service (my firt service !
> .cs...)
> > Well it compile and install successfully but it doesn't appear in the
> > service windows.. so I'm unable to start / stop it!
> > do you have any idea ?
> >
> > I use the following command to compile & install:
> > > csc /nologo /out:myservice.exe MyService.cs
> > > InstallUtil myservice.exe
>
> You make sure to close and reopen the services mmc? It only queries for
> services when it loads. Had me worried on my first service ;)
>
>


Ryan Trudelle-Schwarz

1/21/2003 3:00:00 AM

0

"Lloyd Dupont" <lloyd@galador.net> wrote
> The mmc service ?
> I see the mmc.exe in the TaskManager but I have no idea which service it
is
> in the Service panel, as they have plain english name there. Nor I could
> find a M... M... C.... something service.
>
> I just wonder, to know about my services state is it correct to do
> Start menu->Setting->Control Panel->Administratiev tools->Services ?

Yes, that is what i'm referring to. The "Services" app is an example of a
MMC snap-in.

Anyway, make sure you close and reopen that app after installing the
service.


Phil Wilson

1/21/2003 8:10:00 PM

0

Choosing Refresh is usually sufficient (F5) to view any changes to the service list.

"Ryan Trudelle-Schwarz" <ryan.mvp@mamanze.com> wrote in message
news:#2$2lCPwCHA.2372@TK2MSFTNGP09...
> "Lloyd Dupont" <lloyd@galador.net> wrote
> > The mmc service ?
> > I see the mmc.exe in the TaskManager but I have no idea which service it
> is
> > in the Service panel, as they have plain english name there. Nor I could
> > find a M... M... C.... something service.
> >
> > I just wonder, to know about my services state is it correct to do
> > Start menu->Setting->Control Panel->Administratiev tools->Services ?
>
> Yes, that is what i'm referring to. The "Services" app is an example of a
> MMC snap-in.
>
> Anyway, make sure you close and reopen that app after installing the
> service.
>
>