MikeHildner Posted August 5, 2004 Posted August 5, 2004 I'm trying to build into my service some license checking, and stop the service if the license is invalid. Calling this method in OnStart(): Private Sub CheckLicense() EventLog1.WriteEntry("Your license has expired. Please contact support to obtain a new license.", EventLogEntryType.Error) 'Application.Exit() 'OnStop() 'Me.Dispose(True) Dim serv As New System.ServiceProcess.ServiceController("My Service Name") serv.Stop() End Sub None of my attempts - Application.Exit, calling OnStop, Me.Dispose and using a ServiceController seem to work. Anyone know how my service can stop itself? Thanks, Mike Quote
MikeHildner Posted August 6, 2004 Author Posted August 6, 2004 After a bunch of googling, I've found out that apparently, it's just not possible to do this. The only work-around I've found is to spawn another process that uses a ServiceController to stop your service. Quote
*Experts* Merrion Posted August 6, 2004 *Experts* Posted August 6, 2004 If you do a sleep(10000) in the OnStart() sub if the license is not present then it will time out and stop itself. Quote Printer Monitor for .NET? - see Merrion Computing Ltd for details
Arch4ngel Posted August 6, 2004 Posted August 6, 2004 Well... that's a work around... but it's plainfully ugly. Admit it ! :p lollll Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
MikeHildner Posted August 6, 2004 Author Posted August 6, 2004 Thanks Merrion, that does work. Maybe not too pretty as Arch4ngel said, but it does the job. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.