我正在尝试打开.docx文件并使用Interop.Word.Application转换为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();

最佳答案

如果您仍在寻找答案,我刚刚在我的项目中找到了答案。

打开“DCOM配置”设置:

  • 开始-> dcomcnfg.exe
  • 计算机
  • 本地计算机
  • 配置DCOM
  • 搜索Microsoft Word 97-2003 Documents->属性

  • 制表Identity,从Launching User更改为Interactive User

    07-26 04:25
    查看更多