• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

c# windows service

Hi,

I've been looking at creating a windows service is c# for an engine I am writing.  The question I have is when it's implemented does the windows service run in it's own application domain.

I suppose the question is does the windows service code have a managed .net wrapper. Also whats the advantages of writing it as a windows service, compared to implementing it as c# class library.


Bob.
0
scope_creep
Asked:
scope_creep
  • 4
  • 3
1 Solution
 
ozymandiasCommented:
Not sure what you mean about the application domain.

Writing a service in C# means simple extending System.ServiceProcess.ServiceBase and implementing the  methods :

protected override void OnStart(string[] args)
protected override void OnStop()
protected override void OnPause()
protected override void OnContinue()

I suppose you could implement it as a dll but you would still need an entry point and by default with service projects you get an exe.
0
 
scope_creepAuthor Commented:
Hi ozymandias

I'm not really to bother how its implemented, as long as its get done correctly. With a dll you don't get
get an exe as you need to instantiate the dll from an exe. Anyway, what i'm asking is can you do remoting to a windows service and send .net remote events.

Bob.


0
 
scope_creepAuthor Commented:
Hi ozymandias,

I've also thought, is it possibel for a windows service to have its own log file.

regards
Bob.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ozymandiasCommented:
>> can you do remoting to a windows service and send .net remote events

Not sure  on this one, but I see no reason why not.

>> is it possibel for a windows service to have its own log file.
Yes, of course. It is just a normal windows program. As long as the account used to run the service has the correct priviledges the service can do anything.
It can certainly create and write to a log file or the event log.
I have done both with services in the past.
0
 
ozymandiasCommented:
>> can you do remoting to a windows service and send .net remote events

Looking at this again the answer is yes.
The service itself would probably be a server in the sense that it listens for the evnts on a cannel/port and then invokes event handling methods or classes when it receives a call.

There is an example of thsi here : http://msdn2.microsoft.com/en-US/library/6z5ezzh0.aspx.

The only difference being the the server.cs in the example would be written as a service.
0
 
scope_creepAuthor Commented:
Hi ozymandias,

I found some samples for it on codeproject. Its seems they can host .net remote objects, have their own log file, outside the event log for fine and coarse grain logging.

Only question I have remaining does it allow you to host web services, which I suspect it probably will.

regards
Bob.
0
 
scope_creepAuthor Commented:
Hi ozymandias,


Thats ideal. Bob.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now