473,320 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

using a windows service in c#

nabh4u
62
hi friends,
i have a project where i get the ipaddress ping thing. i want to create a windows service which calls it or runs the thread in the project.
i just want to know how do we call the methods of the project in the windows service project.
following is a sample i tried:
Expand|Select|Wrap|Line Numbers
  1. protected override void OnStart(string[] args)
  2.         {
  3.            Start();
  4.         }
  5.  
  6.         protected override void OnStop()
  7.         {
  8.             Stop();
  9.         }
where start and stop are the functions i want to call from the project.
i got some eroor when i tried to build this project like:
The name 'Start' does not exist in the current context
i dont know how exactly to call those methods.

one more thing as to how to run the windows service project.
i tried by searching on goolge which states like:
type this at command prompt
InstallUtil C:\tgol\Myservice\Bin\Myservice.exe

i dont understand what this tgol is?
and when i tried this command with my file name i got error like:
'InstallUtil' is not recognized as an internal or external command,
operable program or batch file.

please suggest me some solution.
thank you
Jun 18 '07 #1
1 1550
Unless I am mistaken the thing with Services is that in order to actually run them you have to install them.

That is what the InstallUtil.exe is for. This utility comes with the .Net frameworks. You can use it by typeing C:\Pathtoit\Installutil /parametersyouneed

or for easy do a search on your C:\ drive (ctrl+F) and look for Installutil when you find it (odds are it will be an exe i believe) move it to your C:\WINDOWS\system32 folder and then you will be able to run installutil from your command line.

http://msdn2.microsoft.com/en-us/library/50614e95(vs.80).aspx
will show you how to use the utility.

InstallUtil C:\tgol\Myservice\Bin\Myservice.exe
C:\tgol\Myservice\Bin\Myservice is just the path to the Myservice.exe in the example you are looking at.


In .Net 2005 you can add an Installer by going to (Default names used) Service1.cs[Design] and right click one of the options will be "Add Installer"

http://msdn2.microsoft.com/en-us/library/aa984263(VS.71).aspx
should be some help.

Now, in both .Net 2003 and .Net 2005 there is a template for a Windows Service.Onstart and onstop functions are only called by the service when it starts and stops hence the names. Generaly you would have the onstart do your initialization of timers or event watchers etc... and use your onstop to do cleanup or writing to file etc...Not sure when you want it to play with the IP address but you might want to look into Events and EventHanders and EventWatchers etc...

Hope thats somewhat helpful.
Jul 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: grutta | last post by:
I am writing a windows service that will recieve notification when a USB Device is insterted into the machine. I have used the RegisterDeviceNotification and the RegisterServiceCtrlHandlerEx with...
2
by: raghavendra | last post by:
Hi, How to run automatically windows service by using setup deployment insatllation script using visual studio 2003.? What i did is :-- 1. created a windows service & tested the same. 2....
5
by: Derek Martin | last post by:
I am creating a windows service and have added a reference to a DLL project that I have created. That DLL file is correctly referenced in both a windows app and a web app, all in the same...
0
by: grutta | last post by:
I am writing a windows service that will recieve notification when a USB Device is insterted into the machine. I have used the RegisterDeviceNotification and the RegisterServiceCtrlHandlerEx with...
3
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
Now I have a web application, a web service and a SQL Server database. The Web application will invoke the web service, the web service invokes the SQL Server stored procedure. I let the web...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.