What is the different between Window Application and Window service?

Joined
Oct 10, 2006
Messages
6
Programming Experience
Beginner
Hi,

I have developed an window application, and I want to make it run as a window service. The application run so fine when being triggered from the application's interface, perform all the update to the respective database tables. However, when I try to run the same functions as a window service, the tables never get updated. Could anyone advise how could I test the application as a window service? or what is the different between running the application just like normal window application and running as a window service??

Any reply is greatly appreciated!!
 
Hi Neal,

Thank you for your reply.

I know window service doesn't have an interface. The problem I've got is, I move all the update coding from the "form_load" to a VB class, when the window service be started, it will just trigger the coding in the VB class, so.. no interface will be involved. The application update everything perfectly when it is being triggered by "form_load", but once being put into window service triggered, it is not doing the updating anymore.

any idea why? anyone?
 
It's important to get the concepts straight to get a proper understanding of what's going on. Things aren't triggered by "form_load". .NEt applications are event-driven. That means applications are notified when something (an event) happens and they can then respond. When a Windows Form is displayed it raises the Load event. You can handle that event in your code with a method and thus execute code when a form loads. That's what you're talking about: handling the Load event of your Windows application's startup form.

In a Windows Service project you would put that initialisation code in the OnStart method, which is executed when a service starts up.

If in doubt, go to MSDN: Introduction to Windows Service Applications
 
sorry for my poor expression.

I have put the initialisation code in the OnStart method and installed the service using Installutil.exe

The way I test the program is:

I installed the service namely : test_service
1) I start the service from the administrative tool->service
2) attach the process during debugging by Debug->process->test_service->Attach
3) once the service started, it will stop at the breakpoint that i have inserted in the test_service.vb
4) then i step thru the coding to debug my program.

my problem here is :

the coding retrieve all the desired source data, however, it does not update the tables when i test it in the above way.

Whereby, when i put the exact same coding into an window application, and start by the Load event of the Window application's startup form, the tables are being updated.

am i missing something when i test it using the window service way?
 
There's no reason that a service shouldn't be able to update a database. Without any indocation of what code you're using or any error messages you may be getting there's not much more we can say. How do you know that the tables aren't being updated? How exactly are you testing that?
 
Hi,

Just would like to share with you guys that I have found the solution to my problem. Apparently, there are settings for the service. In the service properties menu -> Log On tap

we need to logon as Local System Account, and also need to check the "Allow service to interact with desktop".

Once that option is checked, the data is being updated to the database correctly.

Thanks you for everyone who have helped out with my question here.

Cheers,
 
Back
Top