Skip to content

GUEST POST: Testing a Windows Service Application with Xojo

When working with Windows services you’ll want to debug the application while it’s running as a service. To do this, you can Select Run Paused from the project menu, then create the windows service and start it. Now you’re debugging your app while it runs in service mode.

All of this takes time, and having to create/start the service each time slows down debugging considerably.

I have written a little utility that allows me to right click on the debug executable and automate the service creation and startup. You can download this utility from The source for the Xojo project is included. The utility accepts the executable path as its argument, creates a service “_test” and starts the service.

After downloading the zip file expand it somewhere and create a shortcut. Copy the shortcut to %APPDATA%MicrosoftWindowsSendTo and you’re ready to roll!

To test this out create a new project using the Empty Service template. Replace the contents of the RUN event with:

For i As Integer = 0 to args.Ubound
  System.DebugLog Str(i) + ” ” + ReplaceAll(args(i), “”, “”)
Next i


If you run this normally you will see args(0 & 1) are printed to the debug log and both will be the name of the executable file.

Now select run paused, right click on the executable and select Send To ServiceDebug.

This time you’ll see args(0 & 1), but args(0) is the program executable while args(1) is the service name.

Running services.msc will show you the service _test (at the top of the list) is running. You can either stop the service here or use the stop button in the Xojo IDE.

To see the debug log messages right in the IDE click on the icon.

It is important to be able to test in this environment as permissions and folders change. Stand-alone web applications are based on the Windows Service Template so these can be debugged using the same method.


About the Author:

Wayne Golding has been using Xojo since 2005, mostly developing client server applications using Windows services and desktop apps. He now also does a lot of web development.