>This still works ok from the Services interface. But, when clicking on the EXE, it is still the same thing.Which same thing? An error message about service not being installed or it starts and then immediately stops? If it's the latter, then you need to have a Console.ReadLine() between the OnStart and OnStop.
I didn't go back and look at your previous code, but in the code you just posted you're using toWindowsService.OnStart() and toWindowsService.OnStop() ... but those methods are protected, not public. So, what have you done there? (I suppose I'll just go back and look at your previously posted code.) That's why MyService has public Start() and Stop() methods, so that I can call them from the static Main (and they in turn call the .OnStart() and .OnStop()).
>>I think you missed some of my code. I have two parts, one when running as a Service, uses ServiceBase.Run():
>
>Thanks, I had simplified too much.
>
>This is what I have now:
>
>
> Protected Shared Sub Startup(toArgs As String(), toWindowsService As WindowsService)
>
> ' If this from the Windows Service
> If Not Environment.UserInteractive Then
> Run(toWindowsService)
> Else
> toWindowsService.OnStart(toArgs)
> toWindowsService.OnStop()
> End If
>
> End Sub
>
> Protected Overrides Sub OnStart(ByVal toArgs As String())
> MyBase.OnStart(toArgs)
>
>
>This still works ok from the Services interface. But, when clicking on the EXE, it is still the same thing.
>
>I installed the service with sc. I do not know if this could be a factor.