Solved

c# windows service

Posted on 2006-11-10
7
246 Views
Last Modified: 2010-04-16
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
Comment
Question by:scope_creep
  • 4
  • 3
7 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17914327
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
 

Author Comment

by:scope_creep
ID: 17914372
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
 

Author Comment

by:scope_creep
ID: 17914453
Hi ozymandias,

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

regards
Bob.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 15

Expert Comment

by:ozymandias
ID: 17914536
>> 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
 
LVL 15

Accepted Solution

by:
ozymandias earned 350 total points
ID: 17914635
>> 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
 

Author Comment

by:scope_creep
ID: 17914643
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
 

Author Comment

by:scope_creep
ID: 17914662
Hi ozymandias,


Thats ideal. Bob.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now