c# - 无法加载文件或程序集 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

标签 c# asp.net .net pdf office-interop

我正在尝试将 docx 文件转换为 pdf,并且已成功在我的本地电脑上转换为 pdf。

我在 visual studio 2010 中遵循的步骤是

click on Add reference --> Click to COM -->select "Microsoft Word 12.0 Object Library" and cliked ok

我的网络配置被修改并添加了程序集

<add assembly="Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>

我将 doc 转换为 pdf 的 .cs 代码是

using Microsoft.Office.Interop.Word;//Name Space


protected void Page_Load(object sender, EventArgs e)//Coading on page load
{

    Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application();
    wordDocument = appWord.Documents.Open(Server.MapPath("~/convert/goodquest.docx"));
    wordDocument.ExportAsFixedFormat(Server.MapPath("~/convert/goodquest.pdf"), WdExportFormat.wdExportFormatPDF);
}

public Microsoft.Office.Interop.Word.Document wordDocument { get; set; }

所有在本地都能正常工作,但是当我上传时,所有这些都在web上发生了变化。

错误如

Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.

出现了。 我该如何解决这个问题

我还尝试从链接 Here 下载“Microsoft Office 2010:Primary Interop Assemblies Redistributable”但是当我按照我之前告诉过你的步骤“点击添加引用-->点击COM...... "

最佳答案

Microsoft.Office.Interop.Word.dll 复制粘贴到服务器的 bin 文件夹中。

可以添加到这个路径

%ProgramFiles%\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\ 但我不知道它是否正确:更多详细信息请参阅此 MSDN链接

否则,您可以下载此 dll:https://stackoverflow.com/a/6309218/2218635

关于c# - 无法加载文件或程序集 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20866895/

相关文章:

c# - 从多个工作线程 (.NET) 更新 UI

c# - C#中如何抓取TCP数据包

c# - FormsAuthentication authCookie 仅对某些用户为 null

Javascript 更改 asp :textbox visible property to true

asp.net - 有用的 ASP.NET 模块?

asp.net - PayPal API,账户验证

asp.net - 预览失败 - Visual Studio 在发布时将查找 typescript 文件,即使它们不包含在内

抽象父类(super class)中的 c# static 将在子类之间共享?

c# - 将 C# 对象发送到 webapi Controller

c# - 如何使类中的属性线程安全