我的一位同事編寫了一個.NET Windows服務,它將.doc轉換爲.docx文件。爲了實現這一目標,他使用了Office 2007兼容包隨附的wordconv.exe。爲什麼wordconv.exe在.NET窗口服務中調用時會隨機返回-14
大多數時間一切正常,但在某些情況下,我們還無法再現,wordconv.exe不會轉換,但會返回exitcode -14。
不幸的是,這個錯誤只發生在我們客戶的生產環境中。我們無法重現開發或集成系統中的錯誤。
我們用下面的代碼:
Process converter = new Process();
converter.StartInfo.FileName = <Path to wordconv.exe>;
converter.StartInfo.Arguments = string.Format("-oice -nme \"{0}\" \"{1}\"", fileIn, fileOut);
converter.StartInfo.CreateNoWindow = true;
converter.StartInfo.WindowStyle = ProcessWindowStyle.hidden
converter.StartInfo.UseShellExecute = false;
converter.StartInfo.RedirectStandardError = true;
converter.StartInfo.RedirectStandardOutput = true;
converter.Start();
converter.WaitForExit(intervall);
int exitCode = converter.ExitCode;
感謝您的回答!我認爲/希望這不是問題,因爲我們沒有做任何com自動化,只是一些「命令行風格」調用。不過,我會研究這個! – 2009-06-22 13:15:20
但是wordconv在內部做什麼......? – 2009-06-22 13:21:52
因爲它沒有安裝MS Office的副本,我希望,它不會做任何辦公室com自動化魔術;-) – 2009-06-22 13:39:44