Coverting VB.Net applications to services
I have a basic VB.Net application that gets data from some websites and then send them to a MS-SQL database automatically. I have develop开发者_高级运维ed it as a desktop application with a WinForm front end with logs writing to the WinForm continuously.
Now, is it possible to convert the Winform to a Windows services so that I do not need to keep it opening in front of my PC and watching the logs, instead, it runs quietly in the background and the data gets logged into the system log viewer?
Many thanks!
In Visual Studio choose File->New Project and in the Windows templates you'll see Windows Service. Choose that option and then start migrating your code. If you kept most to all of your non-UI code in a separate DLL it will be easy because then you can have your service reference that library.
The following MSDN link has step by step instructions on how to get started with Windows Services but the answer is it not possible to convert your application but you can create a new windows service and copy your code across. This should be quite trivial.
If you have a specific interval to run the project, then you can use windows schedular to have the executable invoked as per your requirement and interval. However, as answered earlier, to convert your project to win services, you need to create the windows services from scratch and what you can do is, keep your business logic classes seperate and have objects created from the component classes.
精彩评论