VB.Net / Acrobat-用户手动退出程序后Acrobat挂起 [英] VB.Net / Acrobat - Acrobat hangs after user manually exits program

查看:235
本文介绍了VB.Net / Acrobat-用户手动退出程序后Acrobat挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在VB.Net和Adobe Acrobat上遇到问题。问题来自退出Acrobat,但Windows任务栏仍指出有一个Acrobat.exe进程打开。我尝试使用 Marshal.ReleaseComObject(),但它仍然挂在那里。我不想依靠任务栏上的结束进程选项来删除它。

I'm currently having an issue with VB.Net and Adobe Acrobat. The issue comes from exiting Acrobat but the Windows Taskbar still states that there is an Acrobat.exe process open. I have tried using Marshal.ReleaseComObject(), but it still hangs there. I do not want to have to rely on the "End Process" option on the Task bar in order to remove it.

下面是我尝试使用的代码段:

Below is a snippet of the code that I am try to using:

Try
   'Tries To Close Acrobat Application
        acrobatApp.Exit()
        System.Runtime.InteropServices.Marshal.ReleaseComObject(javaScriptObj)
        javaScriptObj = Nothing
        System.Runtime.InteropServices.Marshal.ReleaseComObject(acroPDDoc)
        acroPDDoc = Nothing
        System.Runtime.InteropServices.Marshal.ReleaseComObject(acrobatAVDoc)
        acrobatAVDoc = Nothing
        System.Runtime.InteropServices.Marshal.ReleaseComObject(acrobatApp)
        acrobatApp = Nothing

   'Below is a snippet of code that I found for garbage collecting, but it did not work
        'GC.Collect()
        'GC.WaitForPendingFinalizers()

    Catch ex As Exception
        'Acrobat Could Be Closed Already
    End Try

尽管我不确定这是否会成为问题m-我在Acrobat端运行javascript saveAs脚本,以制作文件副本。这也可能是它挂起的原因,但是我基于保存文件并退出其他Acrobat / Microsoft程序的基本知识将其排除。

Although I am not sure if this could be a problem - I run a javascript saveAs script on the Acrobat side in order to make a copy of the file. This also could be a reason why it is hanging, but I ruled it out based on basic knowledge of saving files and exiting from other Acrobat/Microsoft Programs.

任何帮助都可以有好处!
谢谢!

Any Help would be beneficial! Thanks!

编辑:-我忘了提到Acrobat仅在我的应用程序结束时关闭。 (当前)我正在尝试考虑如果用户手动关闭Acrobat应用程序的情况。

-I forgot to mention that Acrobat only closes when my application ends. (Currently) I am trying to make it consider the case if a user manually closes the Acrobat application.

推荐答案

我想我会并不是唯一遇到此问题的人,所以我想出了一个肮脏的答案。尽管这不是回答问题的最常规方法,但是可以通过此过程完成。

I figure I would not be the only one having trouble with this, so I came up with a "dirty answer" to this question. Although it is not the most conventional way of answering this question, it can be done through this process.


  1. 获取已打开的acrobat文件总数。 / li>
  2. 循环浏览所有打开的Acrobat文件-并将文件名存储到临时数据结构(arrayList,array等)中

  3. 运行 acrobatApp .CloseAllDocs(), acrobatApp.Exit()和一个杀死整个Acrobat进程的函数。

  4. 从VB端重新打开文档-使用以下链接:

  5. 显示Acrobat。

  1. Get total opened acrobat files.
  2. Loop through the entire opened Acrobat files - and store the file names into a temp data structure (arrayList, array, etc)
  3. run the "acrobatApp.CloseAllDocs()", "acrobatApp.Exit()", and a function that kills the entire Acrobat Process.
  4. Re-Open the documents from the VB side - use the links that were stored inside the data structure.
  5. Display Acrobat.

If acrobatApp IsNot Nothing AndAlso acrobatApp.GetNumAVDocs > 0 Then
        Dim docs(acrobatApp.GetNumAVDocs) As String

        'Saving And Formatting Names Of Opened Documents
        For i = 0 To acrobatApp.GetNumAVDocs - 1
            acrobatAVDoc = acrobatApp.GetAVDoc(i)
            acroPDDoc = acrobatAVDoc.GetPDDoc
            javaScriptObj = acroPDDoc.GetJSObject
            docs(i) = javaScriptObj.path().ToString.Replace("/", "\").Substring(1)
            position = docs(i).IndexOf("\")
            docs(i) = docs(i).Substring(0, position) + ":\" + docs(i).Substring(position + 1)
        Next

        'Closing And Killing Acrobat Application
        acrobatApp.CloseAllDocs()
        KillAcrobat()

        'Creating New Instance Of Acrobat
        acrobatApp = CreateObject("AcroExch.App")

        'Opening All Previously Opened Documents
        For i = 0 To docs.Length - 1
            acrobatAVDoc = CreateObject("AcroExch.AVDoc")
            acrobatAVDoc.Open(docs(i), Path.GetFileName(docs(i)))
        Next

        'Displaying The Application
        acrobatApp.Show()

    End If


这篇关于VB.Net / Acrobat-用户手动退出程序后Acrobat挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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