First, please do not respond with general advice so as not to automate Word on the server or link to the MS web page "how to automate the word on the server if you really should." I know about it.
I have a process that runs as a Windows service and uses .Net OLE interop to automate Office (mostly just Open and SaveAs). This code worked reliably for 8 years on literally hundreds of servers, using many combinations of versions of Windows and Office, both 32 and 64 bits, so I am glad that the mechanism is reliable. Still...
With Server 2012 R2, it works with PowerPoint and Excel, but does not try 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:
- failure in all documents
- works fine on windows 8.1
- the same problem arose both on the customer’s website and in our test environment, so it is unlikely to be purely environmentally friendly.
- my application uses .Net 3.5
- the code is associated with Interop 2003 assemblies (obviously, later versions of Office are supported by assembly binding redirection).
- we tried this with Office 2013 both 32 and 64 bit with the same results, but did not try earlier versions of the office.
- it does not work, whether the service works as a LocalSystem or as a standard user account
- if we start the maintenance process in the foreground (i.e. literally double-clicking on the executable file) the problem does not happen
Obviously, I have everything I need to research, but it’s interesting to know if anyone else has seen this particular problem, even if you haven’t solved it. Please note that there are many difficulties and problems with office automation, so if your symptoms are not very similar to mine, you probably do not have the same problem.
ms-word ms-office automation office-interop
Andy
source share