title: Powerpoint Process works in standalone console project, but not integrated project
body: <p>I'm trying to run a local process using C# to call Powerpoint and convert a .pdf to a .ppt.</p>
  
  <p>I made a standalone console app, in hopes of reproducing and isolating the problem.
  Unfortunately, it works for the standalone version, but not with the integrated version.</p>
  
  <p>When it doesn't work, it throws no exceptions. It just silently fails to create the .pdf file.</p>
  
  <h2>NEW:</h2>
  
  <p>I'm getting an error on the event log:</p>
  
  <pre><code>Microsoft PowerPoint
  PowerPoint can't do this because a dialog box is open. Please close the dialog box to continue.
  P1: 400205
  P2: 15.0.4420.1017
  </code></pre>
  
  <p>I don't see any sort of dialog box when running the console commands, the standalone console application, or running the integrated web project on my local machine.</p>
  
  <p>The /pt command is supposed to be silent, as per <a href="http://office.microsoft.com/en-us/powerpoint-help/command-line-switches-for-powerpoint-2007-and-the-powerpoint-viewer-2007-HA010153889.aspx" rel="nofollow">the official documentation</a>.</p>
  
  <p>I can set the <code>Identity</code> of the <code>ApplicationPool</code> the project is running under to the user that I log in as, and I no longer get the above error in the event log. However, I get no other errors (that I can tell are related) from the event log.</p>
  
  <p>It still doesn't work, however. Powerpoint or PDFCreator still crashes, and doesn't create the .pdf.</p>
  
  <p>I also tried to run my working console app by calling it as a <code>Process</code> from my integrated issue, and that didn't work either.</p>
  
  <h2>The working console application:</h2>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System;
  using System.Diagnostics;
  using System.Text;
  
  namespace ConsoleApplication3
  {
      class Program
      {
          static void Main(string[] args)
          {
  
          var psi = new ProcessStartInfo();
          psi.FileName = "\"C:\\Program Files\\Microsoft Office\\Office15\\POWERPNT.exe\"";
          psi.Arguments = "/pt \"PDFCreator\" \"\" \"\" dd0e03ff-f386-4e65-b89d-72c7f1ee502d.pptx";
          psi.WorkingDirectory = "C:\\Temp";
          psi.CreateNoWindow = true;
          psi.ErrorDialog = true;
          psi.UseShellExecute = false;
          psi.WindowStyle = ProcessWindowStyle.Hidden;
          psi.RedirectStandardOutput = true;
          psi.RedirectStandardInput = false;
          psi.RedirectStandardError = true;
          try
          {
              using (Process exeProcess = Process.Start(psi))
              {
                  exeProcess.PriorityClass = ProcessPriorityClass.High;
                  var outString = new StringBuilder(100);
                  exeProcess.OutputDataReceived += (s, e) =&gt; outString.AppendLine(e.Data);
                  exeProcess.BeginOutputReadLine();
                  var errString = exeProcess.StandardError.ReadToEnd();
  
                  if (!string.IsNullOrEmpty(errString))
                  {
                      Console.WriteLine("errors reported 1");
                  }
              }
          }
          catch (Exception ex)
          {
            ex.ToString();
            Console.WriteLine("Errors reported 2 ");
            Console.WriteLine(ex.ToString());
          }
  
          Console.WriteLine(psi.FileName);
          Console.WriteLine(psi.Arguments);
          Console.WriteLine(psi.WorkingDirectory);
      }
  }
  }
  </code></pre>
  
  <p>It prints</p>
  
  <pre><code>"C:\Program Files\Microsoft Office\Office15\POWERPNT.exe"
  /pt "PDFCreator" "" "" dd0e03ff-f386-4e65-b89d-72c7f1ee502d.pptx
  C:\Temp
  </code></pre>
  
  <h2>The not working integrated application:</h2>
  
  <pre><code>using System;
  using System.Diagnostics;
  using System.Text;
  
  namespace CT.Services.Helper
  {
      public static class ExecutableRunner
      {
          public static ExecutableResult RunExeNamed(string exeFilename, string commandLineArgs)
      {
          return RunExeNamed(exeFilename, commandLineArgs, null);
      }
  
      public static ExecutableResult RunExeNamed(string exeFilename, string commandLineArgs, string workingDirectory)
      {
          var result = new ExecutableResult { WasSuccessful = true };
  
          var psi = new ProcessStartInfo();
          psi.FileName =  "\""+exeFilename+"\"";
          psi.Arguments = commandLineArgs;
          if(!string.IsNullOrEmpty(workingDirectory))
          {
              psi.WorkingDirectory = workingDirectory;
          }
          psi.CreateNoWindow = false;
          psi.ErrorDialog = true;
          psi.UseShellExecute = false;
          psi.WindowStyle = ProcessWindowStyle.Hidden;
          psi.RedirectStandardOutput = true;
          psi.RedirectStandardInput = false;
          psi.RedirectStandardError = true;
          try
          {
              // Start the process with the info we specified.
              // Call WaitForExit and then the using statement will close.
              using (Process exeProcess = Process.Start(psi))
              {
                  exeProcess.PriorityClass = ProcessPriorityClass.High;
                  var outString = new StringBuilder(100);
                  // use ansynchronous reading for at least one of the streams
                  // to avoid deadlock
                  exeProcess.OutputDataReceived += (s, e) =&gt; outString.AppendLine(e.Data);
                  exeProcess.BeginOutputReadLine();
                  // now read the StandardError stream to the end
                  // this will cause our main thread to wait for the
                  // stream to close (which is when ffmpeg quits)
                  var errString = exeProcess.StandardError.ReadToEnd();
  
                  if (!string.IsNullOrEmpty(errString))
                  {
                      result.WasSuccessful = false;
                      result.ErrorMessage = errString;
                  }
              }
          }
          catch (Exception ex)
          {
              result.WasSuccessful = false;
              result.ErrorMessage = ex.ToString();
          }
          Debug.WriteLine(psi.FileName);
          Debug.WriteLine(psi.Arguments);
          Debug.WriteLine(psi.WorkingDirectory);
          return result;
      }
  }
  
  public class ExecutableResult
  {
      public bool WasSuccessful { get; set; }
  
      public string ErrorMessage { get; set; }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>it prints</p>
  
  <pre><code>"C:\Program Files\Microsoft Office\Office15\POWERPNT.exe"
  /pt "PDFCreator" "" "" dd0e03ff-f386-4e65-b89d-72c7f1ee502d.pptx
  C:\Temp
  </code></pre>
  
  <p>I would think that one of the strings I'm using as the file path or console command would be wrong, so I had them printed to the console, but you can see that those aren't the issue.</p>