c# - axAcroPDFLib 在关闭问题 C#

标签 c# pdf axacropdf

我使用从 Adob​​e Reader 9 安装中获取的 axAcroPDFLib 控件在我的 C# 窗口窗体应用程序中显示和打印用户 PDF 文档。一切正常,直到应用程序关闭...

它抛出以下错误:

The instruction at "0x0700609c" referenced memory at "0x00000014". The memory could not be read

我的 FormClosing 方法很简单,我认为是错误的,但我不知道如何以正确的方式做到这一点:

private void Form2_FormClosing(object sender, FormClosingEventArgs e)
    {
        if (axAcroPDF1 != null)
        {   
            axAcroPDF1.Dispose();

        }
    }

提前感谢任何想法

最佳答案

我刚刚想出了如何正确关闭应用程序:

    [System.Runtime.InteropServices.DllImport("ole32.dll")]
    static extern void CoFreeUnusedLibraries();

    private void Form2_FormClosing(object sender, FormClosingEventArgs e)
    {
        if (axAcroPDF1 != null)
        {                                
            axAcroPDF1.Dispose();                
            System.Windows.Forms.Application.DoEvents();
            CoFreeUnusedLibraries(); 
        }
    }

有了这个,就不会抛出错误了:D

关于c# - axAcroPDFLib 在关闭问题 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1359616/

相关文章:

c# - 向 TextBox 添加静态文本

c# - Dot Net Core 2.0 多重cookie

java - 如何打开 PDF 文件

loops - 如何在 gnuplot 中仅选择少数图输出为 pdf

c# - 如何在 AxAcroPdf 中获取 pdf 文件的页数?

c# - C#取算符

c# - 尝试通过客户端库获取 TFS 用户列表

java - 使用 OOo 在 java 中将文档转换为 pdf

c# - 如何检测AxAcroPdf组件是否加载了PDF?

c# - 将 PDF 嵌入到 WPF 应用程序中