COMException (0x800A13E9) - Word interop services

10,694

Solution 1

Here's the solution I found:

  1. Put a folder called Desktop on C:\Windows\SysWOW64\config\systemprofile (Yes I know. WTF?)
  2. Open Regedit, Go to HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppId and edit the two enteries that have a Guid ending with 46. Delete every key they have and add a new key called RunAs with the value of Interactive User

After that, start praying. It doesn't work if you access through a terminal server. Which is kind of a problem for me hehe.

EDIT: The problem with the terminal server was that only an Administrator is allowed to raise COM objects so what you have to do is impersonate to an Administrator.

Solution 2

Sorry 'bout that 1MB reference... I just had to jump on that one.

When automating Office Applications make sure, that you use a local account on the server with permissions for the Word COM+ object as well as the documents you are trying to work on.
There are several posts relating to your problem pointing at the account issue:

Share:
10,694
the_drow
Author by

the_drow

My name is Omer Katz and I am a very passionate software developer who specializes in ALM & SCM practices. I'm also an Agile & Lean enthusiast and practitioner. I am only 23, therefor I have only started working in the industry in 2010 but I have been programming since I was 11 and I have never stopped being passionate about it. I have a vast knowledge when it comes to planning, designing, developing & delivering software. My greatest passion is finding new ways to make the developers' lives easier and let them focus on what they know to do best, software development.

Updated on June 04, 2022

Comments

  • the_drow
    the_drow almost 2 years

    I am getting this stacktrace:

    System.Runtime.InteropServices.COMException (0x800A13E9): Word ðú÷ì ááòéä.
       at Microsoft.Office.Interop.Word.Documents.Add(Object& Template, Object& NewTemplate, Object& DocumentType, Object& Visible)
       at Crm.DocumentGeneration.Printing.DocumentsPrinter.MergeDocuments(ApplicationClass& wordApp, IEnumerable`1 printDataItems, String tempDirectory, String template) in C:\Work\Danel.Nursing\Crm.DocumentGeneration.Printing\DocumentsPrinter.cs:line 249
    

    After googling a bit it seems that COMException (0x800A13E9) is out of memory exception but there is enough memory on the server to launch a spaceship 8192 spaceships.
    Here is the function call:

    Document document = wordApp.Documents.Add(ref defaultTemplate, ref missing, ref missing, ref missing);
    

    Nothing is null or invalid with defaultTemplate, I checked.

  • DarinH
    DarinH over 13 years
    +1 for this comment about running word on the server. Actually that might not the the greatest idea in the world in any case. what you might have better luck with is setting up a separate machine, that receives "requests" to generate documents FROM the webserver, generates them and then signals the webserver to pick them up. Might be simpler in the long run.
  • the_drow
    the_drow over 13 years
    I am using Open XML. The problem is that I need something to print with and word can do that.
  • the_drow
    the_drow over 13 years
    from 'C:\Work\Danel.Nursing\Crm.DocumentGeneration.Printing\Docum‌​entsPrinter.cs' parhaps
  • Bender
    Bender almost 13 years
    Wow, the Desktop folder fixed things for me. I had already mucked around with Component Services setting permissions on the DCOM object for Word so maybe that made your step 2 unnecessary for me. But the folder thing definitely made things start working on Windows Server 2008 for me. Thanks.
  • the_drow
    the_drow almost 13 years
    @sliderhouserules: You're very lucky than.
  • Bill Sambrone
    Bill Sambrone over 12 years
    This just saved me from bashing my head open with my keyboard. All I needed was creating the desktop folder, and it worked great.
  • the_drow
    the_drow over 12 years
    @BillSambrone: It might break at some point. Just making sure you know that. Prefer desktop apps for communicating with COM objects.