PRB: COM Objects Fail to Print When Called From ASP
ID: Q184291
|
The information in this article applies to:
SYMPTOMS
A COM object that sends output to a printer fails when called from Active
Server Pages (ASP), but functions correctly when called from an interactive
application. This COM object could be either a commercial product such as a
Microsoft Office application, or a custom third-party object. A common
error message is "ClassName error '800a01e2' Printer error."
CAUSE
The standard APIs that most objects use to print depend on registry entries
located in HKEY_CURRENT_USER. This registry hive is dynamic. Depending on
which user context the process is running under, different information will
be loaded into this hive. ASP pages run under IIS, which is running as the
SYSTEM account. When you create an instance of a COM object in your ASP
code, by default, it will also run as the SYSTEM account. By default, the
SYSTEM account does not have any printers set up in the registry.
RESOLUTION
There are two ways of solving this problem. The first method is to
configure the Windows NT Server to instantiate the COM object as a specific
user rather than the same user as the process creating the instance. The
second method is to set up printers for the SYSTEM account.
Method 1: Running the Object as a Specific User
If the COM object is implemented as an InProc server (a DLL), you can
install the object into a package in Microsoft Transaction Server, and
configure that package to run as a specific user.
- Launch the Transaction Server Explorer by selecting Programs from the
Start button. Then select Windows NT 4.0 Option Pack, Microsoft
Transaction Server, and Transaction Server Explorer
- Right-click the Packages Installed folder, and select New and then
Package.
- Click on Create an Empty Package.
- Give the package a name.
- Choose to run the package as This user, and supply account and password
information.
- Expand your new package by right-clicking the Components folder, and
selecting New and then Component.
- Click Import components that are already registered.
- Find your components in the list, and select them.
- Click Finish.
If the COM object is implemented as a LocalServer (an EXE), you can
configure that object using Dcomcnfg.exe to run as a specific user.
- Launch DCOMCNFG by clicking the Start button, selecting Run and typing
Dcomcnfg.exe in the Run dialog box.
- In the Applications tab, find your component and click on the Properties
button.
- On the Identity tab, select to run the application as This user:, and
supply account and password information.
Method 2: Installing Printer(s) for the SYSTEM account
This method requires you to modify the registry using the Registry Editor.
WARNING: Using Registry Editor incorrectly can cause serious, system-wide
problems that may require you to reinstall Windows to correct them.
Microsoft cannot guarantee that any problems resulting from the use of
Registry Editor can be solved. Use this tool at your own risk.
- Ensure that the user you are currently logged into on the server has the
desired printers installed.
- Launch the Registry Editor (Regedit.exe).
- Select the following key:
HKEY_CURRENT_USER
\Software\Microsoft\Windows NT\Current Version\Devices
- From the Registry menu, click Export Registry File.
- In the File Name text box, type c:\Devices.reg.
- Select the following key:
HKEY_CURRENT_USER
\Software\Microsoft\Windows NT\Current Version\PrinterPorts
- From the Registry menu, click Export Registry File.
- In the File Name text box, type c:\PrinterPorts.reg.
- Select the following key:
HKEY_CURRENT_USER
\Software\Microsoft\Windows NT\Current Version\Windows
- From the Registry menu, click Export Registry File.
- In the File Name text box, type c:\Windows.reg.
- From the Start button, select Run. Open Devices.reg in Notepad by
typing Notepad Devices.reg in Run dialog box.
- Replace the text HKEY_CURRENT_USER with HKEY_USERS\.DEFAULT
- Save the file. Then import it into the registry by double-clicking the
file in Windows Explorer.
- Repeat steps 13 through 15 for PrinterPorts.reg and Windows.reg.
REFERENCES
For the latest Knowledge Base articles and other support information on
Visual InterDev and Active Server Pages, see the following page on the
Microsoft Technical Support site:
http://support.microsoft.com/support/vinterdev/
For additional information, please see the following article in the
Microsoft Knowledge Base:
Q152451
: Applications Run from the Schedule Service Fail to Print
(c) Microsoft Corporation 1998, All Rights Reserved.
Contributions by John Lewis, Microsoft Corporation.
Keywords : kberrmsg kbASP kbASPObj kbCOMt kbSecurity kbGrpASP
Version : WINNT:
Platform : winnt
Issue type : kbprb
Last Reviewed: May 27, 1999