What's missing in this service?

K

K Viltersten

I've followed the section on MSDN on how to
create a service but it seems that when i
install it, i get an error about an
attribute named RunInstallerAttribute.Yes
missing.

As far i haven't seen any info on that for
a basic case of a service. Where should it
go and what does it look like?

namespace MySpace
{
class ServiceRunner : ServiceBase
{
ServiceRunner()
{
this.ServiceName = "PageroLink";
this.CanStop = true;
this.CanPauseAndContinue = true;
this.CanShutdown = true;
this.CanHandlePowerEvent = false;
}
public static void Main()
{
ServiceBase.Run(new ServiceRunner());
}
protected override void OnStart(string[] args)
{
Console.WriteLine("Service commenced.");
}
protected override void OnStop()
{
Console.WriteLine("Service ceased.");
}
}
}
 
C

Claus Konrad

Hi

The class with the class-level attribute RunInstaller(true) is the installation class for your service.
This is the class responsible for registrering the service(s) with the SCM (Service Control Manager) and writing entries into Registry in Windows.

There is no need to create a custom installer if you do not have special requiremens during the installation process, which I sense you do not.
Add a ordinary installer via your control-designer surface and it will work.

/Claus Konrad
 
C

Claus Konrad

To add an installer:
Right-click on your service and press "Add Installer". This will add the installer class to your service and this very installer class will carry the RunInstaller(true) attribute for your. You do not need to worry about these things though. Just add the installer and you should be fine...

/Claus Konrad
 
I

Ignacio Machin ( .NET/ C# MVP )

I've followed the section on MSDN on how to
create a service but it seems that when i
install it, i get an error about an
attribute named RunInstallerAttribute.Yes
missing.

As far i haven't seen any info on that for
a basic case of a service. Where should it
go and what does it look like?

namespace MySpace
{
  class ServiceRunner : ServiceBase
  {
    ServiceRunner()
    {
      this.ServiceName = "PageroLink";
      this.CanStop = true;
      this.CanPauseAndContinue = true;
      this.CanShutdown = true;
      this.CanHandlePowerEvent = false;
    }
    public static void Main()
    {
      ServiceBase.Run(new ServiceRunner());
    }
    protected override void OnStart(string[] args)
    {
      Console.WriteLine("Service commenced.");
    }
    protected override void OnStop()
    {
      Console.WriteLine("Service ceased.");
    }
  }

}

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.

Hi,

Right click in the design panel of your service and select Add
Installer.
Then add a setup project to your solution, add the primary output of
your service.
I know there is another step, adding a custom action maybe?? Let me
check ...
 
K

K Viltersten

The class with the class-level attribute RunInstaller(true) is the installation class for your service.
This is the class responsible for registrering the service(s) with the SCM (Service Control Manager) and writing entries into Registry in Windows.

There is no need to create a custom installer if you do not have special requiremens during the installation process, which I sense you do not.
Add a ordinary installer via your control-designer surface and it will work.

According to
http://msdn.microsoft.com/sv-se/lib...ess.serviceprocessinstaller(en-us,VS.80).aspx
i should see [RunInstallerAttribute(true)] and not the
one you mentioned. What's up with that?
 

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