[Ironpython-users] ironpython and windows services

Peter Schwalm ps at peter-schwalm.de
Thu Jan 3 15:34:55 CET 2013


Hello,
I am trying to convert an Ironpython filewatcher program into a windows 
service. I started by translating a c# example to ipy. I tried to simply 
use System.ServiceProcess.ServiceBased, and received a message

"AttributeError: attribute 'ServiceProcess' of 'namespace#' object is 
read-only"

I also failed to import System.ServiceProcess.

I also tried to add a Reference to System.ServiceProcess.dll, and even 
that did not work.

Here are the code snippets ...

     # coding: latin-1
     import System
     import clr
     #clr.AddReference("System.ServiceProcess.dll")  # fails
     #import System.ServiceProcess                   # fails
     from System import Array

     class Program:
         @staticmethod
         def Main():
             x = System.ServiceProcess.ServiceBase   # fails
             print dir(x)
             ServicesToRun = 
System.Array[System.ServiceProcess.ServiceBase](
                 [
                 FolderWatch()
                 ])
             ServiceBase.Run(ServicesToRun);

     prg = Program()
     prg.Main()

Does anyone have an idea, how to accomplish that or - more generally - 
how to make an windows service out of an ipy program?

Thanks in advance
Peter Schwalm




More information about the Ironpython-users mailing list