Cannot open Word document after publishing (Office.Interop.Word)
I cannot open Word document in c# after publishing to IIS
It can open Word document and replace any text in debug mode by using Microsoft.Interop.Office.Word. When I publish the project, it return the following error:
object reference not set to an instance of an object
Here is my code:
try {
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application { Visible = true };
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref fileName, ReadOnly: false, Visible: true);
doc.Activate();
...
}
The file path is correct. I found that the doc object returns null value.
Working environment:
I try to add IUSR account and set enough permission to the folder which contains Word documents. It stills return the same error message. But it can work properly in debug mode...
Thanks for your help
链接地址: http://www.djcxy.com/p/55926.html