المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Advice on running event log watcher as a service



C# Programming
10-20-2011, 01:22 AM
Greetings Gurus,

Come across a problem I don't seem able to solve and was hoping someone could point me in the right direction.

I am building a Windows service which records Event log entries in a sql db. Running it as a console application works fine but when I try and move the code into a service structure I get errors.

My codepublic partial class GetInfo : ServiceBase { public ServiceName() { InitializeComponent(); //write service start to event log - this works } static AutoResetEvent appsignal, syssignal, secsignal; public static void Main()// this of course causes a build error that the project has more than one entry point defined as program.cs contains the entry point {
What should I use in place of "public static void Main"?

I would like to keep this out of the "Onstart" region because I want it to initialise before the service's timer.

Can you help?