简体   繁体   English

使用PrintDocument时出错

[英]Error when using PrintDocument

I have a dye sub printer, and I'm trying to send an image to print programatically. 我有一台染料子打印机,我正在尝试发送图像以编程方式进行打印。
I'm using PrintDocument and a PrintPage with C# 4.0 on Windows 7 64b. 我在Windows 7 64b上使用带有C#4.0的PrintDocument和PrintPage。
Printing fails, and windows gives this error: 打印失败,Windows给出此错误:

The print spooler failed to load a plug-in module 
C:\Windows\system32\spool\DRIVERS\x64\3\S6145UI.DLL, error code 0xc1

The printer works fine with Window's default Print dialog. 打印机可以在Window的默认“打印”对话框中正常工作。
The code works fine when printing with a regular laser printer. 使用常规激光打印机进行打印时,该代码可以正常工作。
I'm completely stumped. 我完全迷住了。

error code 0xc1 错误代码0xc1

That's ERROR_BAD_EXE_FORMAT. 就是ERROR_BAD_EXE_FORMAT。 Not an uncommon error on the 64-bit version of Windows but rather a major fail whale for a printer driver. 这不是Windows 64位版本上常见的错误,而是打印机驱动程序的主要故障。 You'll get this error when a 64-bit process tries to load a 32-bit DLL. 当64位进程尝试加载32位DLL时,会出现此错误。 Or the other way around. 或相反。

Clearly the driver is at fault here, you should look for an update. 显然,驱动程序在这里出错,您应该寻找更新。 A possible workaround is to force your program to run in another mode, easy to do for a managed program. 可能的解决方法是强制您的程序在另一种模式下运行,这对于托管程序而言很容易做到。 Right-click your EXE project, Properties, Build tab. 右键单击您的EXE项目,“属性”,“生成”选项卡。 Change the Platform target setting, flipping between AnyCPU vs x86. 更改平台目标设置,在AnyCPU和x86之间切换。 On VS2012 toggle the Prefer 32-bit mode checkbox. 在VS2012上,切换“首选32位模式”复选框。 Not actually so sure this will work, the spooler is its own subsystem. 后台打印程序是它自己的子系统,实际上并不确定是否可以正常工作。 I think there's a way to force the spooler to run in 32-bit mode for legacy printer drivers, ask about it at superuser.com 我认为有一种方法可以使后台打印程序针对旧版打印机驱动程序以32位模式运行,请在superuser.com上进行询问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM