Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Windows Service stopping immediately
Message
De
01/09/2013 20:56:20
 
 
À
01/09/2013 20:36:00
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01581778
Message ID:
01581814
Vues:
37
Yes, you've got your stuff set up a little bit differently than mine. Probably because you didn't start it off with being a Console app. Mine assumes a Console app and the static Main is where I launch everything. Your's looks like it's different, like you've got the calls to OnStart and OnStop in your Service. I don't think you want your base Service class starting your Services. That should be done from the Main entry point into the Console app. I think that if you refactor it a bit to be like mine, you'll probably get it working the way you want to.

~~Bonnie



>>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.
>
>The Console.ReadLine() was necessary. I must have missed that one.
>
>>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()).
>
>As is, presently, when I click on the EXE, I can see that the application runs. It appears on the Task Manager and disappear. So, the Timer doesn't get initiated when I click directly on the EXE. This must be related to the infrastructure you just mentioned.
>
>Presently, the base class is like this:
>
>
>    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)
>            Console.ReadLine()
>            toWindowsService.OnStop()
>        End If
>
>    End Sub
>
>    Protected Overrides Sub OnStart(ByVal toArgs As String())
>        MyBase.OnStart(toArgs)
>
>
>So, those methods are protected. But, I'll have to switch a few things in here to adopt your approach to see if that will help.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform