Microsoft MVP성태의 닷넷 이야기
.NET Framework: 121. WPF - PrintTicket provider failed to bind to printer. [링크 복사], [링크+제목 복사],
조회: 22623
글쓴 사람
정성태 (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

비밀번호

댓글 작성자
 




... 151  152  153  154  155  156  157  [158]  159  160  161  162  163  164  165  ...
NoWriterDateCnt.TitleFile(s)
1096정성태8/15/201125637디버깅 기술: 42. Watson Bucket 정보를 이용한 CLR 응용 프로그램 예외 분석 - (2)
1095정성태8/14/201126097디버깅 기술: 41. Windbg - 비정상 종료된 닷넷 프로그램의 StackTrace에서 보이는 offset 값 의미
1094정성태8/14/201130435오류 유형: 131. Fiddler가 강제 종료된 경우, 웹 사이트 방문이 안되는 현상
1093정성태7/27/201124077오류 유형: 130. Unable to connect to the Microsoft Visual Studio Remote Debugging Monitor ... Access is denied.
1092정성태7/22/201126450Team Foundation Server: 46. 코드 이외의 파일에 대해 소스 제어에서 제외시키는 방법
1091정성태7/21/201125471개발 환경 구성: 128. WP7 Emulator 실행 시 audiodg.exe의 CPU 소모율 증가 [2]
1089정성태7/18/201131045.NET Framework: 234. 왜? Button 컨트롤에는 MouseDown/MouseUp 이벤트가 발생하지 않을까요?파일 다운로드1
1088정성태7/16/201124183.NET Framework: 233. Entity Framework 4.1 - 윈도우 폰 7에서의 CodeFirst 순환 참조 문제파일 다운로드1
1087정성태7/15/201126801.NET Framework: 232. Entity Framework 4.1 - CodeFirst 개체의 직렬화 시 순환 참조 해결하는 방법 - 두 번째 이야기파일 다운로드1
1086정성태7/14/201128264.NET Framework: 231. Entity Framework 4.1 - CodeFirst 개체의 직렬화 시 순환 참조 해결하는 방법 [1]파일 다운로드1
1085정성태7/14/201128689.NET Framework: 230. Entity Framework 4.1 - Code First + WCF 서비스 시 EndpointNotFoundException 오류 - 두 번째 이야기파일 다운로드1
1084정성태7/11/201133990.NET Framework: 229. SQL 서버 - DB 테이블의 데이터 변경에 대한 알림 처리 [4]파일 다운로드1
1083정성태7/11/201128038.NET Framework: 228. Entity Framework 4.1 - Code First + WCF 서비스 시 EndpointNotFoundException 오류
1082정성태7/10/201127598.NET Framework: 227. basicHttpBinding + 사용자 정의 인증 구현 [2]파일 다운로드1
1081정성태7/9/201126935VC++: 53. Windows 7에서 gcc.exe 실행 시 Access denied 오류 [2]
1080정성태7/8/201125415웹: 23. Sysnet 웹 사이트의 HTML5 변환 기록 - 두 번째 이야기파일 다운로드1
1079정성태7/6/201129858오류 유형: 129. Hyper-V + Realtek 랜카드가 설치된 시스템의 BSOD 현상 [2]
1078정성태7/5/201137405VC++: 52. Chromium 컴파일하는 방법 [2]
1077정성태6/24/201135030.NET Framework: 226. HttpWebRequest 타입의 HaveResponse 속성 이야기파일 다운로드1
1076정성태6/23/201129157오류 유형: 128. SQL Express - User Instance 옵션을 사용한 경우 발생하는 오류 메시지 유형 2가지
1075정성태6/21/201124791VS.NET IDE: 69. 윈폰 프로젝트에서 WCF 서비스 참조할 때 Reference.cs 파일이 비어있는 경우
1074정성태6/20/201124872.NET Framework: 225. 닷넷 네트워크 라이브러리의 트레이스 기능파일 다운로드1
1073정성태6/20/201127100오류 유형: 127. Visual Studio에서 WCF 서비스의 이름 변경 시 발생할 수 있는 오류
1072정성태6/19/201126561.NET Framework: 224. EF 4.1 Code First에서 Identity 칼럼 생성하는 방법파일 다운로드1
1071정성태6/19/201130070.NET Framework: 223. Entity Framework 4.1의 Code First를 이용한 SQL Azure 데이터베이스 생성 [3]파일 다운로드1
1070정성태6/19/201127599.NET Framework: 222. Windows Azure - VM Role 베타 프로그램 참여 [2]
... 151  152  153  154  155  156  157  [158]  159  160  161  162  163  164  165  ...