.net sukbir

Dear All,

I am creating a windows service. So I have put my supposing code in the

protected override void OnStart(string[] args). The problem now is how can I verify if my code is working or not because I tried to use MessageBox.show but is not available. So how to run my windows service base on interval of every 20 minutes. I dont how to go about installing it and testing it. Any help please. Thanks.



Re: Visual C# General Windows Service Install and verifying help

_Henock_

The best way to know what your service is doing is by leveraging event log. You can use the event log similar to the way one uses Debug.Writeline(). As for intervals, I use ManualResetEvent's WaitOne method to block the worker thread spawned from the OnStart for 20 minutes .




Re: Visual C# General Windows Service Install and verifying help

.net sukbir

Dear Henock,

Thanks about the event log. I dont get you how to set the interval time. Also I need to how to install it as a service into my O.s. How run exactly I am not sure about it. Thanks.





Re: Visual C# General Windows Service Install and verifying help

_Henock_

First, create an installer to your service and eventlog using the Installer class.

Once you build your project, use the InstallUtil.exe located in "<root>\Windows\Microsoft.Net\Framework\<version>" folder (with -u switch to uninsall).

As for setting the interval, you can set interval constant in your App.Config file and issue a WaitOne command on the AutoEventReset so it can notify the worker thread






Re: Visual C# General Windows Service Install and verifying help

.net sukbir

Dear Henock,

I am really sorry I am very new to .net technology in this terms. So I dont know to create an installer and eventlog using the installer. I am using visual studio 2005. I manage to locate the InstallUtil.exe but when I double click it just open and close immediately. So how to go about can you please guide me Thanks.





Re: Visual C# General Windows Service Install and verifying help

_Henock_

InsallUtil doesn't have UI; It is a command-line executable.

As for creating custom installer, read this...

http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfSystemServiceProcessServiceInstallerClassTopic.asp

 






Re: Visual C# General Windows Service Install and verifying help

.net sukbir

Dear Henock,

I went through this article and also few other articles. I found that some say must have a main function besides the onStart. So I have to manually create it is it I am infact very lost please help me. Thanks.





Re: Visual C# General Windows Service Install and verifying help

.net sukbir

Dear Henock,

I have manage to build my windows service with the install. But the problem when I start to install with the installutil.exe it as me for user name and password . So here I get stuck I put my login name but it rollback. I use the startup type as automatic. Must I change to any other like account or manual is it Thanks.





Re: Visual C# General Windows Service Install and verifying help

_Henock_

Which account is the service installer set to run under




Re: Visual C# General Windows Service Install and verifying help

.net sukbir

Dear Henock,

I have set to run under User account with is a administrator with no password. The username is just user. So do you think there is a problem with this Thanks.





Re: Visual C# General Windows Service Install and verifying help

_Henock_

I would set up the service to run under the LocalSystem account.... as in ProcessInstaller.Account=ServiceAccount.LocalSystem




Re: Visual C# General Windows Service Install and verifying help

.net sukbir

Dear Henock,

How to do the account settings I dont have any idea how to do this Sorry cause I am very new to this





Re: Visual C# General Windows Service Install and verifying help

_Henock_

See the link I sent you in the previous post; it has an example on how to do this...




Re: Visual C# General Windows Service Install and verifying help

.net sukbir

Dear Henock,

Thanks man I got it at last. I have another simple question is that where will by Debug.Write will be written Where can I find the log file for this write Thanks.