gpt4 book ai didi

c# - FoxIt PDF SDK - PrintWithDialog 中的 AccessViolationException

转载 作者:太空宇宙 更新时间:2023-11-03 23:42:11 24 4
gpt4 key购买 nike

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

我们有 0.01% 的用户无法打印我们通过 FoxIt PDF SDK ActiveX v5.0.1 呈现的文档

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

异常堆栈跟踪是:

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、记事本等都可以毫无问题地打印。

最佳答案

如果我删除默认打印机设置(意味着没有打印机设置为默认设置),我可以模拟这种情况,因此临时将以下窗口注册表项从“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)按预期工作(只需要手动选择打印机)

关于c# - FoxIt PDF SDK - PrintWithDialog 中的 AccessViolationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28674731/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com