Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.ComponentModel.Win32Exception (0x80004005): No such interface supported

Having an issue with a program that is launched by a windows service.

The process flow is

  • exe launches
  • renames itself to *.bak
  • downloads the latest version of itself
  • calls Restart()
  • does a bunch of file and SQL operations (updating our main software suite)
  • then calls Restart()
  • Process flow starts again. IF there were no software updates for the main suite it does not restart

this all works perfect except for one customer site

On one site, the first Restart() works, but the second one always throws an exception.

System.ComponentModel.Win32Exception (0x80004005): No such interface supported at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at UpdateCompanionService.Program.Restart()

It is a WS2008 standard server.

public static void Restart()
{
  try
  {
      var procPath = Path.Combine(Config.UpdateCompanionDirectory, "UpdateCompanionService.exe");
      Logger.Debug("Starting procecss {0}", procPath);

      var proc = new Process
      {
          StartInfo = {FileName = procPath, WorkingDirectory = Config.UpdateCompanionDirectory, Arguments = "/noupdate", UseShellExecute = true}
      };

      proc.Start();
      Environment.Exit(-1);
  }
  catch (Exception e)
  {
      Logger.Fatal("Error restarting update companion", e);
  }
}
like image 647
TheRealTy Avatar asked Feb 12 '15 05:02

TheRealTy


2 Answers

Try using

    UseShellExecute = false 

Its been known to fix this problem

like image 198
BoldAsLove Avatar answered Sep 28 '22 08:09

BoldAsLove


You can try to set UseShellExecute = false in your code.

I remember some own problems long ago, where I even recompiled the original .NET framework code to find out that setting this flags uses a completely different method of starting.

For me it seems you do not need UseShellExecute = true in your case.

If this does not work, you should check security context / GPO settings, e.g. "Is this service running as SYSTEM or (domain) user ?"

Also be sure that your new EXE with all additional components is "ready" at the time where you try to restart it (maybe you use a background thread which did not complete).

like image 39
Rainer Schaack Avatar answered Sep 28 '22 07:09

Rainer Schaack