为什么从 .NET Windows 服务调用时 wordconv.exe 会随机返回 -14

发布于 2024-07-25 02:16:57 字数 804 浏览 4 评论 0原文

我的一位同事编写了一个 .NET Windows 服务,可以将 .doc 转换为 .docx 文件。 为了实现这一目标,他使用了 Office 2007 兼容包附带的 wordconv.exe。

大多数时候一切都工作正常,但在某些情况下我们还无法重现,wordconv.exe 不会转换,但返回退出代码 -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;

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.

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.

We're using the following code:

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;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟火散人牵绊 2024-08-01 02:16:57

好的,我们刚刚发现了问题。 我们的客户保存了带有 doc 扩展名的 docx 文件。 后来他们尝试将此 docx 转换为 docx。 使用 Office 兼容包的 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.

南冥有猫 2024-08-01 02:16:57

我想知道 wordconv 是否与 Office 的其他部分遭遇同样的命运 - 即 在服务应用程序中不受支持。 因此,可能会发生奇怪的事情......

I wonder whether wordconv is suffering the same fate as the rest of Office - i.e. not supported in a service application. As such, freaky things may happen...

您能否将问题与特定的输入文档联系起来?

如果不能,您能否确保始终只有一个 wordconv.exe 实例在运行?

可能不支持并行的多个进程(我只是胡乱猜测;我们有一个服务基本上执行相同的调用,但我们还没有遇到这样的问题)。

Can you tie the problem to specific input documents?

If you can't can you make sure that there is always only a single instance of wordconv.exe running?

It might be that several processes in parallel might not be supported (I'm just wildly guessing; we have a service basically doing the same call but we haven't faced such a problem yet).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文