Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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.
Posted
Well... that's a work around... but it's plainfully ugly. Admit it ! :p lollll

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...