MK_E_UNAVAILABLE in Marshal.GetActiveObject("Word.Application")

1

0x800401E3 (MK_E_UNAVAILABLE) error occurs in my case when UAC (User Account Control) isn't set to the un-restrictive "Never Notify Me".

Microsoft.Office.Interop.Word.Application wd = (Microsoft.Office.Interop.Word.Application) System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");

The error is thrown when the code is run after publishing and installing the project. While debugging in the editor instead, everything is fine.

Is this due to security settings or credentials ? How to write such code correctly pls ?

Win Word is open and a document is open too, of course, and this code has always worked fine with UAC set to "Never Notify Me".

c#
asked on Stack Overflow Apr 6, 2013 by user2.252.275 • edited Apr 8, 2013 by user2.252.275

1 Answer

1

Running word as a service is nasty business see for instance here . I went through quite a few problems making it work. The way I made it work was to run it in separate process which launches it only once. The main program communicates with the process by sending commands as strings to stdin of the process and waiting for response on the stdout. If the response does not come in time allotted the process is killed and restarted

answered on Stack Overflow Apr 6, 2013 by mfeingold

User contributions licensed under CC BY-SA 3.0