Note that there are some explanatory texts on larger screens.

plurals
  1. POService not found after installing using AssemblyInstaller
    primarykey
    data
    text
    <p><strong>Context</strong> </p> <p>Windows 2008 64 bit.<br> I have a .NET service installed that acts as an installer.</p> <p><strong>Background</strong></p> <p>I'm using this code (credit: Marc Gravell) to install a service:</p> <pre><code>using (var inst = new AssemblyInstaller(typeof(MyNamespace.Program).Assembly, new string[] { })) { IDictionary state = new Hashtable(); inst.UseNewContext = true; try { if (uninstall) { inst.Uninstall(state); } else { inst.Install(state); inst.Commit(state); } } catch { try { inst.Rollback(state); } catch { } throw; } } </code></pre> <p><strong>The Problem</strong></p> <p>All works fine and no exceptions, but right after that, I try to run the following code to start the service just installed:</p> <pre><code>using (var sc = new ServiceController("the service's name")) { sc.Start(); sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(20)); } </code></pre> <p>And I get an exception:</p> <pre> System.InvalidOperationException: Service [service name goes here] was not found on computer '.'. ---> System.ComponentModel.Win32Exception: The specified service does not exist as an installed service --- End of inner exception stack trace --- at System.ServiceProcess.ServiceController.GenerateNames() at System.ServiceProcess.ServiceController.get_ServiceName() at System.ServiceProcess.ServiceController.Start(String[] args) at System.ServiceProcess.ServiceController.Start() at ... (my code details) </pre> <p>I don't understand why, because:</p> <ol> <li>The service's name is the exact one as in the <code>ServiceInstaller</code> (in the <code>ServiceName</code> property)</li> <li>The code is executed inside a different service, which runs under <em>Local System</em> account.</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload