Solved

c# windows service

Posted on 2006-11-10
7
248 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

785 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