简体   繁体   English

关闭问题C#的axAcroPDFLib

[英]axAcroPDFLib at closing problem C#

Im using a axAcroPDFLib control taken from a Adobe Reader 9 installation to show and print user PDF documents within my C# window forms application. 我使用来自Adobe Reader 9安装的axAcroPDFLib控件在我的C#窗体应用程序中显示和打印用户PDF文档。 Everything works just fine untill the appication close... 一切正常,直到申请结束......

It throws the following error: 它会引发以下错误:

The instruction at "0x0700609c" referenced memory at "0x00000014". “0x0700609c”处的指令引用“0x00000014”处的存储器。 The memory could not be read 无法读取内存

My FormClosing method is quite simple and i think is wrong, but i didn't know how to do it in the right way: 我的FormClosing方法很简单,我认为是错误的,但我不知道如何以正确的方式做到这一点:

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

        }
    }

thanks in advance for any idea 提前感谢任何想法

I just figured out how to close the application properly: 我只想弄清楚如何正确关闭应用程序:

    [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(); 
        }
    }

with this, no error is thrown :D 有了它,不会抛出任何错误:D

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM