我使用从 Adobe 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/