为什么 wordconv.exe 从 .NET Windows 服务调用时会随机返回 -14 [英] Why does wordconv.exe randomly return -14 when called from a .NET windows service
问题描述
我的一位同事编写了一个 .NET Windows 服务,可将 .doc 转换为 .docx 文件.为了实现这一目标,他使用了 Office 2007 兼容包附带的 wordconv.exe.
One of my coworkers wrote a .NET windows service that converts .doc to .docx files. In order to accomplish that goal, he uses wordconv.exe which comes with the office 2007 compatibility pack.
大多数情况下一切正常,但在某些情况下我们还无法重现,wordconv.exe 不会转换,但会返回退出代码 -14.
Most times everything works fine, but under certain circumstances wich we weren't able to reproduce yet, wordconv.exe doesn't convert, but returns exitcode -14.
很遗憾,此错误仅发生在我们客户的生产环境中.我们无法重现开发或集成系统中的错误.
Unfortunately, this error only occurs in our customers production environment. We weren't able to reproduce the error in the development or integration system.
我们使用以下代码:
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;
推荐答案
好的,我们刚刚发现问题.我们的客户使用 doc 扩展名保存了 docx 文件.后来他们尝试将这个 docx 转换为 docx.使用办公兼容包的 GUI 一切正常.甚至 Word 也能在没有警告消息的情况下打开伪造的"文档.
Ok, we just found the problem. Our customer saved docx files with a doc extension. Later they tried to convert this docx to docx. Using the GUI of the office compatiblity pack everything worked fine. Even Word opened the "faked" doc file without a warning message.
这篇关于为什么 wordconv.exe 从 .NET Windows 服务调用时会随机返回 -14的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!