PrintDocument.Print()投げWin32Exception
-
19-09-2019 - |
質問
もしかしたら不思議な例外から以下のコード:
var printDialog = new PrintDialog();
printDialog.ShowDialog();
var printDocument = new PrintDocument { DefaultPageSettings = { Landscape = true, PrinterSettings = new PrinterSettings { PrinterName = printDialog.PrintQueue.Name } } };
var updateResult = new UpdateResult<Image>(UpdateType.Print) { Success = true };
foreach (string location in fileLocation)
{
try
{
_printImage = Image.FromFile(location);
printDocument.PrintPage += PrintRequest;
}
catch (Exception exception)
{
//various error handling code here
}
}
printDocument.Print();
最終ラインを投げるWin32Exceptionの詳細"の取扱いが無効"によると、msdnの文書の例外がスローされはプリンタが見つかりません。例外のようにある種のドライバ/外枠組みます。
私が選択myプリンター(Lexmark T640、セットアップの印刷直接プリンタポートのコードの印刷もののどちらかを選択し、プリンターにしていまへのアクセス(別T640、dell色のコードに失敗します。他のプリンタ設定の印刷を中心にプリントサーバーが持っているときにこのようなことはせます。が他のポインター?
編集:だったのでprintDialog.PrintQueue.Fullnameの行動は変わりありません。置換、ゴミをプリンタ名称するInvalidPrinterExceptionとがこのプリンターがいるように失敗します。
解決 2
のための@マットなのです。なかった管理の問題に上がることにもなりかねないという設定のネットワークが出ます。
代わりに使って別の方法を使ってCommonDialogClass.ShowPhotoPrintingWizard()であるInterop.困ったときは以下のとおり。
http://msdn.microsoft.com/en-us/library/windows/desktop/ms630492%28v=vs.85%29.aspx
この手のプロセスの写真印刷ウィザードといった問題です。
他のヒント
設定してみてくださいをターゲットプリンタのデフォルトとしてプリンタされていない場合、ますか
私はこの例外の場合のみ印刷複数のを提出する。私の解決のために追加
printDocument.Dispose();
後 printDocument.Print();
.