Firstly, please don't reply with the generic advice not to automate Word on a server or a link to the MS web page on "how to automate word on a server if you really must". I am aware of this.
I have a process which runs as a Windows service and uses .Net OLE interop to automate Office (mostly just Open and SaveAs). This code has worked reliably for 8 years on literally hundreds of servers using many combinations of Windows and Office versions, both 32 and 64 bit, so I am happy that the mechanism is reliable. So far...
With Server 2012 R2, it works with PowerPoint and Excel but fails trying to open a word document:
System.Runtime.InteropServices.COMException (0x800A16A0):
The file appears to be corrupted.
at Microsoft.Office.Interop.Word.Documents.Open...
My observations so far which may or may not be relevant:
- fails on all documents
- works fine in Windows 8.1
- the same problem has happened both on a customer site and in our test environment, so is unlikely to be purely environmental
- my application is using .Net 3.5
- the code is linked against the 2003 Interop assemblies (obviously later office versions are supported by assembly binding redirection)
- we have tried it with office 2013 both 32 and 64 bit with the same results, but not tried earlier versions of office
- it fails whether the service is running as LocalSystem or as a standard user account
- if we run the service process in the foreground (i.e. literally double-clicking on the executable) the problem does not happen
Obviously I still have things to investigate but interested to hear if anyone else has seen this specific problem even if you haven't solved it. Please note there are many difficulties and problems with office automation so unless your symptoms are very similar to mine, you probably don't have the same problem.