winforms - 尝试在 C# 中使用 ActiveX 控件加载 PDF 文件时出现 COMException 错误

标签 winforms pdf c#-3.0

我正在使用适用于 Windows 桌面的 VS 2012 Express。

private void button1_Click(object sender, EventArgs e)
{
    DialogResult result = openFileDialog1.ShowDialog();
    if (result == DialogResult.OK)
    {
        axAcroPDF1.LoadFile(openFileDialog1.FileName);
    }
}

我使用Acrobat Reader ActiveX控件;并将其变成一种形式。我正在尝试加载 PDF 文件。但我收到以下错误消息:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Windows.Forms.dll

Additional information: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

最佳答案

您是否有可能在 64 位 Windows 上构建“x64”目标或“任何 CPU”?根据这篇文章Using Adobe Reader in a WPF app Acrobat DLL 是 32 位,因此必须在“x86”32 位版本中运行。

Quote from article: “Also as there is not currently an x64 version of the Acrobat DLL it is wise to ensure that the target platform is set to x86 (this is on the build tab of the project properties), otherwise an error along the lines of {"Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))"} will occur – pretty cryptic if you ask me!”

关于winforms - 尝试在 C# 中使用 ActiveX 控件加载 PDF 文件时出现 COMException 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15182052/

相关文章:

c# - 从 C# 调用对话窗口

c# - 系统.反射

c# - 我如何从目录中获取所有文件,包括子目录?

c# - 读取 json 文件并使用 JSON.NET 更改它

winforms - 将 VB6 项目转换为 .net- 引用错误?

.net - DataGridView 仅数字单元格?

Java iText 使用外部签名签署 PDF - 容器大小估计

c# - list.Sort ArgumentException 错误 : IComparer doesn't not return 0(null)

php - 用 PHP 编辑 PDF?

javascript - 来自HTML图像的jsPDF导致pdf为空