tags:

views:

603

answers:

4

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;
A: 

This is more of a comment then an answer (I can't comment yet):

I'm not sure what exitcode -14 is, but I wonder if the file is locked by another process?

mlsteeves
Thanks for your answer / comment. Unfortunately, we don't know either what -14 is (there's no documentation, or at least we couldn't find one). Anyway I don't think that we have a locking issue. What we could figure out (using process monitor) so far is that the converter works in the following sequence: 1. Read original (.doc) file 2. Write something to a newly created temp file in the users temp folder 3. Wirte something to a newly created tempfile in the temporary internet files\content\word folder 4. Write the converted (new) file to it's destination.
Andre Kraemer
A: 

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...

Marc Gravell
Thank's for your answer! I think / hope that this isn't the problem because we're not doing any com automation, but just some "command line style" calls. However, I'll research that!
Andre Kraemer
But what does wordconv do internally...?
Marc Gravell
As it works without an installed copy of ms office I hope, that it doesn't do any office com automation magic ;-)
Andre Kraemer
OK - fair enough. It sounds like this isn't the issue, then. Sorry for adding confusion, but I think it was at least worth investigating.
Marc Gravell
It doesn't require an installed version of Office, but Compatibility Pack itself installs quite a bit, e.g. mso.dll which is a core component of Office.
0xA3
+1  A: 

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).

0xA3
Thanks for your suggestion! The problem occurs with different documents. All of them can easily be convertet later. I think that we're running multiple converter processes in parallel. I'll check if that's the reason for our problem!
Andre Kraemer
A: 

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.

Andre Kraemer