关闭表单时 AxAcroPDF 控件窗口表单挂起 [英] AxAcroPDF control windows form hangs when closing the form

查看:26
本文介绍了关闭表单时 AxAcroPDF 控件窗口表单挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理用 C# 编写的 windows 窗体 .NET 应用程序,它需要显示具有所有相关功能(旋转对象、更改灯光等)的 3D pdf.我正在使用 AxAcroPDF COM 控件,它运行流畅.问题是,当我尝试关闭放置控件的窗体时,有时它会在处理控件时无缘无故地挂起几秒钟.我在测试期间加载的 3D 文件并不是特别重.独立 adobe 阅读器中的同一个文件可以毫无延迟地打开和关闭.我在 windows 窗体关闭事件中使用以下代码:

I'm dealing with a windows forms .NET application written in C# which needs to display a 3D pdf with all the associated features (rotate the object, change lights and so on). I'm using the AxAcroPDF COM control and it run smoothly. The problem is that when I try to close the form where the control is placed, sometimes it hangs for several seconds with no apparent reason while disposing the control. The 3D file I loaded during the tests is not particulary heavy. The very same file in the standalone adobe reader opens and closes with no particular delay. I'm using the following code within the windows form closing event:

        private void DrawingForm_FormClosing(object sender, FormClosingEventArgs e)
        {
        this.axAcroPDF.Dispose();
        Application.DoEvents();
        CoFreeUnusedLibraries(); }

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

有趣的是,如果刚刚显示文件,表单会正常关闭,但是,当旋转 3D 文件中的对象时,它会在关闭过程中挂起.当它挂起时,会显示手表的图标(与独立的 Adob​​e PDF 中显示的相同).悬挂时间在15-20秒之间.我试图在 webbrowser 控件中显示该文件,但得到了类似的结果.导致此问题的原因是什么?我试图寻找替代的稳定控件,但我没有找到任何支持 3D 的控件.

The interesting thing is that the form closes normally if the file is just displayed, but, when the object within the 3D file is rotated, it hangs during closing. When it hangs, the icon of a watch (the same shown in standalone Adobe PDF) is displayed. The hanging time is between 15-20 seconds. I tried to display the file within the webbrowser control but I got similar results. What can be the cause of this problem? I tried to search for alternative stable controls but I haven't found any with 3D support.

推荐答案

FormClosing 事件处理程序中添加 2 行:

In FormClosing event handler add 2 lines:

this.Controls.Remove(yourAxAcroPDFControl);

yourAxAcroPDFControl = null;在 Adob​​e 进行更新之前,将其视为临时解决方案.我检查了 Adob​​e SDK 示例,这些示例也会导致问题,尽管是由 Adob​​e 自己编写的,因此我们可以期望他们认为这是一个问题.

yourAxAcroPDFControl = null; Consider it a temporary solution until Adobe has an update. I checked Adobe SDK samples and those cause problems too, despite being written by Adobe themselves so we could expect them to consider it a problem.

这篇关于关闭表单时 AxAcroPDF 控件窗口表单挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆