Microsoft KB Archive/324565

= PRB: Errors When Printing from ASP Pages or from Windows Services =

Article ID: 324565

Article Last Modified on 5/10/2006

-

APPLIES TO


 * Microsoft .NET Framework Software Development Kit 1.0 Service Pack 2
 * Microsoft Windows XP Professional
 * Microsoft Windows XP Professional for Itanium-based systems

-



This article was previously published under Q324565



SYMPTOMS
When you print from ASP pages or from Windows Services, no page is ejected, or other errors occur.



CAUSE
The use of the .NET Framework Printing classes is not supported from a service. This includes ASP pages, which generally run in the context of the server service.



RESOLUTION
Any service that is designed to print must directly use the Win32 APIs, instead of the .NET Framework Printing classes.



STATUS
This behavior is by design.



MORE INFORMATION
The use of the Printing classes is not supported from a service or ASP page. Therefore, if printing is required in this scenario, then a second service must be written, using only Win32 APIs. This service would then print at the request of the ASP page or .NET service. The request can be made by means of Interprocess Communication (IPC), such as a named pipe, event, shared section, or similar means.

The following are some cautions for printing from Win32 services:
 * If all the print jobs can be sent with one user's credentials, the service can be run under that user's account and will have access to the printers that are known to that user on that computer.
 * If the service must print using the credentials of one or more users defined at run time, then the service must LogonUser, LoadUserProfile, and ImpersonateLoggedOnUser before printing. If the user has never logged on to the server computer before, the service must also AddPrinterConnection as appropriate. This approach will leave residue behind in the form of printer connections, registry hives, per-user directories on the hard disk, and others.

Keywords: kbdswgdi2003swept kbprb KB324565

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.