Ete*_*l21 2 c# printing wpf winapi printdialog
我正在尝试在WPF应用程序中打印之前显示"打印"对话框.我正在使用此链接中的 Microsoft示例代码
// Create the print dialog object and set options
PrintDialog pDialog = new PrintDialog();
pDialog.PageRangeSelection = PageRangeSelection.AllPages;
pDialog.UserPageRangeEnabled = true;
// Display the dialog. This returns true if the user presses the Print button.
Nullable<Boolean> print = pDialog.ShowDialog();
Run Code Online (Sandbox Code Playgroud)
它在最后一行崩溃,但有以下异常:
PrintTicket提供程序无法绑定到打印机.Win32错误:打印机名称无效.
我试图寻找一个解决方案,人们建议的两个解决方案是安装打印机服务器功能,并切换到任何CPU版本,但这些都不适用于我的情况.
我创建了另一个空白项目,只有Microsoft的代码,它工作正常.我开始比较两个项目设置,它们是相同的.最后,结果是导致问题的以下设置:
Debug-> Exceptions ...- Common Language Runtime Exceptions
我在忘记其他事情时忘记了.一旦我取消选中它,我的程序就不再中断异常,并正确显示对话框.
| 归档时间: |
|
| 查看次数: |
2567 次 |
| 最近记录: |