为什么从一个.NET Windows服务叫什么时候wordconv.exe随机返回-14叫什么、时候、Windows、NET

2023-09-04 01:11:22 作者:兔比南菠丸

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

大多数时候一切正常,但在某些情况下至极,我们无法重现然而,wordconv.exe不转换,而是返回退出code -14。

不幸的是,这个错误仅发生在我们的客户生产环境。我们无法重现该错误在开发或集成系统。

我们正在使用下面的code:

 流程转换器=新工艺();
converter.StartInfo.FileName =<路径wordconv.exe取代;
converter.StartInfo.Arguments =的String.Format( - 音色-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 =真;
converter.Start();
converter.WaitForExit(INTERVALL);
INT退出code = converter.Exit code;
 

解决方案

好了,我们才发现这个问题。我们的客户保存的文档** x **文件与文档扩展名。后来他们试图把这个文档** x **到DOC ** x **。使用Office兼容性包一切的GUI工作的罚款。即使Word,而不一条警告消息拉开了伪造doc文件。

我的系统是win7 32位的,然后windows功能中没有internet信息服务,我的电脑

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;

解决方案

Ok, we just found the problem. Our customer saved doc**x** files with a doc extension. Later they tried to convert this doc**x** to doc**x**. Using the GUI of the office compatiblity pack everything worked fine. Even Word opened the "faked" doc file without a warning message.