Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Windows Service stopping immediately
Message
De
01/09/2013 19:55:00
 
 
À
01/09/2013 19:44: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:
01581809
Vues:
36
>With that, I can run it from the EXE but not from the Services. With Run(), I can run it from the Services but not from the EXE as it says:
>
>"Cannot start service from the command line or debugger. A Windows Service must first be installed..."



I think you missed some of my code. I have two parts, one when running as a Service, uses ServiceBase.Run():
if (Environment.UserInteractive == false)
{
	ServiceBase[] ServicesToRun;
	ServicesToRun = new ServiceBase[] 
	{ 
		new MyService(),
	};
	ServiceBase.Run(ServicesToRun);
}
So, the above uses .Run(), but you still need to have .OnStart() and .OnStop() in your service class (MyService in my example). If you don't, then perhaps that where you problem is?

Take another look at the code I posted previously ...

~~Bonnie


>>I don't know why the .OnStart() wouldn't work for you.
>
>With that, I can run it from the EXE but not from the Services. With Run(), I can run it from the Services but not from the EXE as it says:
>
>"Cannot start service from the command line or debugger. A Windows Service must first be installed..."
>
>>No, as I said it's a Console app. You can't have any UI in a Windows Service ... and I'm betting that you might even have problems if you have anything in the code referencing Windows.Forms, even if you only use it when running interactively. The Console app feature works fine. You can use Console.WriteLine() if you want to show message or just use your usual debugging from Visual Studio.
>
>Yes, that's the plan. All that is referring to a form has been/will be updated by the time I am done with this.
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