Sto utilizzando il codice C# per avviare e arrestare la funzione della finestra, ma sto ricevendo questo errore.System.ComponentModel.Win32Exception: Accesso negato Errore
System.ComponentModel.Win32Exception: Access is denied
Per favore aiutatemi.
My Code:
public void StartService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
lblMessage.Text = "Service Started.";
}
catch (Exception ex)
{
//lblMessage.Text = "Error in Service Starting.";
lblMessage.Text = ex.ToString();
}
}
Sei sicuro che l'account utente disponga delle autorizzazioni necessarie per avviare un servizio? Puoi pubblicare la traccia dello stack? –
Vedere anche qui: http://stackoverflow.com/questions/6070295/starting-a-service-in-asp-net-c-with-the-right-permissions –
Stack Trace System.InvalidOperationException: impossibile aprire aspnet_state servizio su computer ".". ---> System.ComponentModel.Win32Exception: Accesso negato --- Fine della traccia dello stack di eccezioni interne --- su System.ServiceProcess.ServiceController.GetServiceHandle (Int32 desiredAccess) su System.ServiceProcess.ServiceController.Start (String [] args) su System.ServiceProcess.ServiceController.Start() su _Default.StartService (String serviceName, Int32 timeoutMilliseconds) – Mahesh