我正在尝试使用Interop.Word.Application打开.docx文件并转换为PDF.它作为控制台应用程序,但如果我在我的Web应用程序中使用它不起作用.我试图看到该文件夹的权限.我给了'网络服务'完全控制,但我仍然没有设置对象引用word.Documents.Open.你能告诉我可能出现什么问题吗?我遇到了这个错误.请告诉我.我很感激任何建议.谢谢.
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
object oMissing = System.Reflection.Missing.Value;
word.Visible = false;
word.ScreenUpdating = false;
string fileName = @"c:\OUTPUT\test.docx");
Document doc = word.Documents.Open(filename, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing);
doc.Activate();
Run Code Online (Sandbox Code Playgroud) 我得到这个堆栈跟踪:
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或无效.