I'm an ASP.Net sorta guy, but had to write a Windows app a while back. Now they want it to run as a service. I'm clueless.
I found a couple dozen examples of service skeletons, and I think they all originated with a MS post and everyone just copied that original one.
My skeleton runs fine and responds to Start and Stop in the Services Console. But when I put a call in to one of my classes, I'm just guessing where it should go.
I put the call to my stuff in OnStart, but my service never starts completely. I get:
![ServiceError1.jpg ServiceError1.jpg](https://csharpforums.net/data/attachments/0/6-3ffa54241ad0ff22c3e24f8ee8390f1c.jpg)
I saw an MS note that said:
![ServiceError2.jpg ServiceError2.jpg](https://csharpforums.net/data/attachments/0/7-a1d5b09e5074b2c15048eec5a2957eeb.jpg)
So knowing that I cannot have long-running code in OnStart, where (and how) do I call my stuff?
I apologize for the probably-obvious question, but I've got WAY too many hours in this and I've got to move on.
Thanks in advance,
Brad
Here's what I've got...:
namespace TeknoMLA
{
classProgram : ServiceBase
{
staticvoid Main(string[] args)
{
ServiceBase.Run(newProgram());
}
public Program()
{
this.ServiceName = "TeknoMLA";
}
protectedoverridevoid OnStart(string[] args)
{
base.OnStart(args);
TeknoMain.TeknoMLA_Main(); //this is the call to my class
}
protectedoverridevoid OnStop()
{
base.OnStop();
}
}//class
}//namespace
I found a couple dozen examples of service skeletons, and I think they all originated with a MS post and everyone just copied that original one.
My skeleton runs fine and responds to Start and Stop in the Services Console. But when I put a call in to one of my classes, I'm just guessing where it should go.
I put the call to my stuff in OnStart, but my service never starts completely. I get:
![ServiceError1.jpg ServiceError1.jpg](https://csharpforums.net/data/attachments/0/6-3ffa54241ad0ff22c3e24f8ee8390f1c.jpg)
I saw an MS note that said:
![ServiceError2.jpg ServiceError2.jpg](https://csharpforums.net/data/attachments/0/7-a1d5b09e5074b2c15048eec5a2957eeb.jpg)
So knowing that I cannot have long-running code in OnStart, where (and how) do I call my stuff?
I apologize for the probably-obvious question, but I've got WAY too many hours in this and I've got to move on.
Thanks in advance,
Brad
Here's what I've got...:
namespace TeknoMLA
{
classProgram : ServiceBase
{
staticvoid Main(string[] args)
{
ServiceBase.Run(newProgram());
}
public Program()
{
this.ServiceName = "TeknoMLA";
}
protectedoverridevoid OnStart(string[] args)
{
base.OnStart(args);
TeknoMain.TeknoMLA_Main(); //this is the call to my class
}
protectedoverridevoid OnStop()
{
base.OnStop();
}
}//class
}//namespace