Microsoft MVP성태의 닷넷 이야기
.NET Framework: 121. WPF - PrintTicket provider failed to bind to printer. [링크 복사], [링크+제목 복사],
조회: 22687
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 


WPF - PrintTicket provider failed to bind to printer.


프린터 설정 대화창을 띄우는 데 문제가 발생했습니다.
코드는 너무 간단합니다. 빈 프로젝트 하나 만들고 다음과 같이 달랑 2 라인을 추가했는데, ShowDialog 호출 후 오류가 발생합니다.

private void button1_Click(object sender, RoutedEventArgs e)
{
    PrintDialog pd = new PrintDialog();
    pd.ShowDialog();
}

PrintDialog 내부의 코드와 네트워크 프린터로 연결된 구형 레이저 프린터간의 뭔가 충돌이 발생하는 것 같다는 정도!

재현 과정도 매우 단순합니다. 위의 코드를 실행시킨 후, 버튼을 누르면 프린터 설정화면이 아래와 같이 뜹니다.

[그림 1: 프린터 설정 대화창]
wpf_print_dialog_error_2.PNG

위의 상태에서, 단지 "삼성 ML-8700G"라는 항목을 선택한 것만으로도 아래와 같이 대화창의 "Apply" 버튼이 활성화 됩니다.

[그림 2: "Apply" 버튼 활성]
wpf_print_dialog_error_3.PNG

이제 그냥 "Cancel" 버튼을 누르면 아래와 같이 예외가 발생합니다.

[그림 3: "Cancel" 버튼 누르면 예외 발생]
wpf_print_dialog_error_4.PNG

System.Printing.PrintQueueException was unhandled
  Message="PrintTicket provider failed to bind to printer. 
           Win32 error: The specified resource type cannot be found in the image file.\r\n"
  Source="ReachFramework"
  PrinterName="\\\\testpc\\삼성 ML-8700G"
  StackTrace:
       at MS.Internal.Printing.Configuration.PTProvider..ctor(String deviceName, Int32 maxVersion, Int32 clientVersion)
       at System.Printing.Interop.PrintTicketConverter..ctor(String deviceName, Int32 clientPrintSchemaVersion)
       at MS.Internal.Printing.Win32PrintDialog.PrintDlgExMarshaler.AcquirePrintTicket(IntPtr devModeHandle, String printQueueName)
    ... [중간 생략] ...
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

뭐 좀... 과정이라도 복잡해야 어떻게 된지 문제라도 좀 분석해 볼텐데... ^^;

웹을 검색해 봐도 딱히 신통한 답이 없네요. 그래서 제가 선택한 방법은, Windows Forms에서 제공되는 프린터 대화창을 사용한 것입니다. 그래서 아래와 같이 코드를 교체하면 문제가 해결된다는. ^^;

private void button1_Click(object sender, RoutedEventArgs e)
{
    System.Windows.Forms.PrintDialog pd = new System.Windows.Forms.PrintDialog();
    pd.ShowDialog();
}



[이 토픽에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 4/6/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 121  122  123  124  125  126  127  128  129  130  131  132  133  [134]  135  ...
NoWriterDateCnt.TitleFile(s)
1704정성태7/2/201421618.NET Framework: 447. w3wp.exe AppPool 재생(recycle)하는 방법 정리
1703정성태7/2/201422463.NET Framework: 446. Assembly.Load를 이용해 GAC에 등록된 어셈블리를 로드하는 방법 [1]파일 다운로드1
1702정성태6/23/201422167Phone: 11. Xamarin.Forms - 2. XAML을 이용한 페이지 개발파일 다운로드1
1701정성태6/23/201434349개발 환경 구성: 229. .NET Reflector + Reflexil 도구를 이용해 DLL 코드 변경 [4]
1700정성태6/23/201421169VS.NET IDE: 89. Visual Studio에서 기본 제공되는 성능 프로파일 [2]
1699정성태6/22/201423973Phone: 10. Xamarin.Forms - 1. Forms 시작하기 [2]파일 다운로드1
1698정성태6/22/201425947.NET Framework: 445. [부연 설명] 쉬운 C# 코드를 어럽게 이해하기 [2]
1697정성태6/22/201421231VS.NET IDE: 88. Visual Studio에서 직접 컴파일하는 IL 언어 확장 도구 - IL Support
1696정성태6/22/201421044.NET Framework: 444. clojure와 C#을 통해 이해하는 Sequence와 Vector 형식의 차이점 [1]
1695정성태6/21/201420041개발 환경 구성: 228. PowerShell ISE에서 (입력 기능이 있는) 콘솔 응용 프로그램을 시작하는 방법
1694정성태6/21/201421185개발 환경 구성: 227. 닷넷 용 ClojureCLR 개발환경 설정
1693정성태6/20/201421509개발 환경 구성: 226. Clojure 언어의 윈도우 개발환경 설정
1692정성태6/19/201432112오류 유형: 231. Visual Studio 2013 한글 버전 설치 오류 - The form specified for the subject is not one supported or known by the specified trust provider
1691정성태6/18/201427339개발 환경 구성: 225. 유닉스 계열의 tail 명령어가 제공되는 PowerShell [1]
1690정성태6/18/201430129개발 환경 구성: 224. DirectShow 예제 구하는 방법 [3]
1689정성태6/18/201426919오류 유형: 230. C++ 가변 인자 사용시 va_start 파라미터 전달 방법 [2]
1688정성태6/15/201420555오류 유형: 229. 갤럭시 노트 3 환경에서 Xamarin 앱 배포 충돌
1687정성태6/15/201426539개발 환경 구성: 223. PowerShell로 Visual Studio 빌드 스크립트 작성파일 다운로드1
1686정성태6/12/201424264Windows: 96. 윈도우 8 - 그림 암호를 이용해 로그인 시 지연 현상을 해결하는 방법 [1]
1685정성태6/10/201430990.NET Framework: 443. 자바 8과 C#의 람다(Lambda) 지원에 대한 비교 [12]
1684정성태6/9/201441129.NET Framework: 442. C# - 시스템의 CPU 사용량 및 프로세스(EXE)의 CPU 사용량 알아내는 방법 [5]파일 다운로드1
1683정성태6/2/201420687오류 유형: 228. CLR4 보안 - yield 구문 내에서 SecurityCritical 메서드 사용 불가 [2]파일 다운로드1
1682정성태6/1/201425923.NET Framework: 441. .NET CLR4 보안 모델 - 3. CLR4 보안 모델에서의 APTCA 역할파일 다운로드2
1681정성태6/1/201421790.NET Framework: 440. .NET CLR4 보안 모델 - 2. 샌드박스(Sandbox)을 이용한 보안 [2]파일 다운로드1
1680정성태6/1/201421297.NET Framework: 439. .NET CLR4 보안 모델 - 1. "Security Level 2"란?파일 다운로드1
1679정성태5/31/201420407.NET Framework: 438. .NET CLR2 보안 모델에서의 APTCA 역할파일 다운로드1
... 121  122  123  124  125  126  127  128  129  130  131  132  133  [134]  135  ...