Running a B4PPC program as an NT Service

lancaster

Member
Licensed User
Longtime User
:sign0085: I have written a B4PPC desktop program to quietly process XML files that arrive on the PC with the intention of running it as a Background Service using INSTSRV.EXE and SRVANY.EXE from the Microsoft Resource kits.

I have one form in the program and I never execute a form.show command. All controls on that form are invisible. Importantly, I do not have any msgbox or any other communication with the user.

The program loads OK as a service however after 1 minute it looks for files to process. Then I get an unhandled exception from the system as follows:

Showing a modal dialog box or form when the application is not running in User Interactive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, ....


This suggests to me that the program is tring to display a message box ... but I don't use message box!


Am I attempting the impossible here?

Dave Lancaster
Worcestershire, UK
 

lancaster

Member
Licensed User
Longtime User
I've found the problem.....

I had an old version of SQLite.dll on the system and in background a messagebox was reporting version incompatibility.

So for good measure I have also copied system.data.sqlite.dll into Windows\System32 and my service runs perfectly.

So I can confirm it is possible to write an NT service with B4PPC as long as it has no user interface and using INSTSRV.EXE and SRVANY.EXE to instantiate it.

I basically have a

do
sleep()
process
loop while true


in place of form1.show at the end of app_start


Excellent!
 
Top