【问题标题】:FoxIt PDF SDK - AccessViolationException in PrintWithDialogFoxIt PDF SDK - PrintWithDialog 中的 AccessViolationException
【发布时间】:2015-04-24 19:58:56
【问题描述】:

场景:WinForms 桌面应用,.Net 2.0

我们有 0.01% 的用户群遇到问题,他们无法打印我们通过 FoxIt PDF SDK ActiveX v5.0.1 呈现的文档

当用户单击“打印”按钮时,我们在查看器控件实例上调用 PrintWithDialog() 方法。此时会抛出访问冲突异常,然后应用程序挂起。打印对话框未显示。没有进一步的用户输入(鼠标、键盘)使其恢复活力,并且必须通过任务管理器终止该进程。

异常堆栈跟踪是:

AccessViolationException - Attempted to read or write protected memory. This is 
often an indication that other memory is corrupt.

   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at FoxitPDFSDKStdLib._DFoxitPDFSDK.PrintWithDialog()
   at AxFoxitPDFSDKStdLib.AxFoxitPDFSDK.PrintWithDialog()
   at MyCode.PDFToolBarButtonClick(Object sender, EventArgs e)

我们无法重现问题,FoxIt 似乎也无法帮助我们,因为我们无法给他们一个重现问题的项目。

我的怀疑指向 Windows 7 和打印设置的组策略控制。我们已成功要求受影响的用户删除并重新安装默认打印机,但一两天后问题又出现了。一个站点的策略设置控制谁可以进行彩色打印,并以不同的方式安装打印机(相同的物理设备)。

有没有人使用过影响打印的 Windows 7 或组策略设置?

编辑:只有 FoxIt 受此问题影响。其他一切 - Acrobat、Word、记事本等都可以毫无问题地打印。

【问题讨论】:

  • 您是否尝试过此处的修补程序? “当您运行基于 .NET Framework 2.0 的应用程序时,会发生 System.AccessViolationException 异常......”support.microsoft.com/kb/975954
  • @Paul Zahra。谢谢。我们会试一试。
  • 如果您进行故障转储,您可能可以获得更多信息,但如果问题出在 FoxIt 的 dll 中,则由他们读取转储并修复它。也就是说,如果您发现某个驱动程序或某事有什么奇怪的地方,您可能能够将其追踪到特定的 dll。 blogs.msdn.com/b/tess/archive/2008/02/04/…
  • 您是否尝试过明确捕获异常以查看可能是什么问题? see this。闻起来像访问/使用 com 对象的权限

标签: c# printing foxit


【解决方案1】:

如果我删除默认打印机设置(意味着没有打印机设置为默认设置),我可以模拟这种情况,因此暂时将以下窗口注册表项从“Device”重命名为“OldDevice”

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device

我的简单表格:

public Form1()
{
    InitializeComponent();
    try
    {
        this.axFoxitPDFSDK1.OpenFile(@"C:\foxit\FoxitPDFActiveX51_Manual.pdf", "");

       this.axFoxitPDFSDK1.PrintWithDialog();
    }
    catch (System.Exception exc)
    {
        Debug.WriteLine(exc.StackTrace);
        Debug.WriteLine(exc.Message);
        if (exc.InnerException != null)
        {
            Debug.WriteLine(exc.InnerException.Message);
        }

    }
}

以及调试的相关输出:

Eccezione first-chance di tipo 'System.AccessViolationException' in mscorlib.dll
'MySOfoxit.vshost.exe' (Gestito (v2.0.50727)): 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll' caricato, caricamento simboli ignorato. Il modulo è ottimizzato e l'opzione 'Just My Code' del debugger è abilitata.
   in System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   in FoxitPDFSDKStdLib._DFoxitPDFSDK.PrintWithDialog()
   in AxFoxitPDFSDKStdLib.AxFoxitPDFSDK.PrintWithDialog()
   in MySOfoxit.Form1..ctor() in c:\foxit\MySOfoxit\Form1.cs:riga 23
Tentativo di lettura o scrittura della memoria protetta. Spesso questa condizione indica che altre parti della memoria sono danneggiate.

我可以提到这个link 作为(也许)触发事件的可能原因之一。其他应用程序(WinWord、Adobe Reader)按预期工作(仅需要手动选择打印机)

【讨论】:

  • 这看起来非常很有希望。在赏金到期之前,我会尽我所能对此进行测试。谢谢。
  • 我现在可以重现您所描述的问题。我会马上联系我们的客户。
  • 已经通过了复制到 FoxIt 的步骤,他们现在已经生成了该组件的修订版本,这似乎在我们受影响的站点上运行良好。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-07
  • 2020-05-25
  • 1970-01-01
  • 1970-01-01
  • 2020-08-31
相关资源
最近更新 更多