COMException(0x800A13E9) - Word互操作服务

the*_*row 8 c# ms-word com-interop

我得到这个堆栈跟踪:

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
Run Code Online (Sandbox Code Playgroud)

谷歌搜索后似乎COMException(0x800A13E9)是内存不足异常,但服务器上有足够的内存来启动太空船 8192太空飞船.
这是函数调用:

Document document = wordApp.Documents.Add(ref defaultTemplate, ref missing, ref missing, ref missing);
Run Code Online (Sandbox Code Playgroud)

我检查过defaultTemplate没有null或无效.

the*_*row 8

这是我找到的解决方案:

  1. 将一个名为Desktop的文件夹放在C:\ Windows\SysWOW64\config\systemprofile上(是的,我知道.WTF?)
  2. 打开Regedit,转到HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppId并编辑两个以46结尾的Guid的进入.删除他们拥有的每个密钥并添加一个名为RunAs的新密钥,其值为Interactive User

在那之后,开始祈祷.如果通过终端服务器访问它不起作用.这对我来说是个问题嘿嘿.

编辑:终端服务器的问题是只允许管理员引发COM对象,所以你要做的就是冒充管理员.