How to create window service to read the xml file
i have to create window service开发者_如何学运维 which read the xml file and and take the node's value to connect the sql server and create the log file i have already created window application for that but i don't know how to create win services.
but i don't know how to create win services.
In Visual Studio Pro and above:
File => New Project => Visual C# => Windows => Windows Service
and see the walkthrough here or howto here.
The most important thing is that during the service startup you only do things like spawn a worker thread. You don't do the real processing in there (otherwise it will timeout when starting the service, and Windows will kill it). Oh, and check what working-folder the service starts with - you might find it is the system folder.
You might want to take a look at TopShelf (http://code.google.com/p/topshelf/), which is as described by their website:
"Topshelf is a lightweight framework for building Windows services using the .NET framework. The key goal of Topshelf is limiting the surface area of service-related code within the application."
It might save you some time when it comes to simplifying the development and deployment of your service.
精彩评论