I have a windows service containing this code:
public static void ExtractTextInner(string source, string destination) { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = EXTRACTOR_EXE_FILEPATH startInfo.Arguments = "\"" + source + "\" \"" + destination + "\""; startInfo.CreateNoWindow = true; startInfo.WindowStyle = ProcessWindowStyle.Hidden; Process process = new Process(); process.StartInfo = startInfo; process.Start(); process.WaitForExit(); int exitCode = process.ExitCode; process.Close(); if (exitCode != 0) { switch (exitCode) { case 1: throw new ApplicationException("IFilter Extraction Failed"); default: throw new ApplicationException("Unknown Exit Code:" + exitCode.ToString()); } } }
The purpose of this code is to run an IFilter extract in a document, we use a separate process, because some IFilters are known to be flaky.
Now this code works fine on Windows 7 and Server 2008 R2 mailboxes, but on Windows Server 2003 WaitForExit immediately throws "A process exception associated with this process object." The process exists and completes its task without problems.
Has anyone seen this? Can anyone shed some light on why WaitForExit will prevent this error?
Additional Information
If I put this code in a console application and run it, it works fine in the Windws Server 2003 window too, so it seems to be a special problem running in the "Service on Windows Server 2003" window.
AnthonyWJones
source share