【问题标题】:COMException error when trying to load PDF file using ActiveX Control in C#尝试在 C# 中使用 ActiveX 控件加载 PDF 文件时出现 COMException 错误
【发布时间】:2013-03-03 03:11:51
【问题描述】:

我正在为 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 文件。但我收到以下错误消息:

未处理的类型异常 'System.Runtime.InteropServices.COMException' 发生在 System.Windows.Forms.dll

附加信息:类未注册(HRESULT 异常: 0x80040154 (REGDB_E_CLASSNOTREG))

【问题讨论】:

  • 已经有数百个关于这个错误代码的问题。在本页右上角的搜索框中输入“0x80040154”。

标签: winforms pdf c#-3.0


【解决方案1】:

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

引自文章:“此外,由于当前没有 x64 版本的 Acrobat DLL,因此明智的做法是确保将目标平台设置为 x86(位于项目属性的构建选项卡上),否则会出错沿着 {“Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))”} 的行会发生——如果你问我,这很神秘!”

【讨论】:

    猜你喜欢
    • 2017-10-05
    • 2014-07-28
    • 2011-04-02
    • 1970-01-01
    • 2012-04-04
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多