How to solve the crystal error on Windows Server 2008  or Windows Server 2008 R2 when application pool is set to run as specific user

Errors in ClickHome 3

Error In: - Selection date advice&LogoURL=Logo.jpg&Username=Lauren Hailwood&UserID=83&ContractID=605&format=pdf&Format=HTML

Error Message: Retrieving the COM class factory for component with CLSID {D7F5D7C3-B06C-4CAC-BC47-A06E66D2EE9B} failed due to the following error: 800703fa Illegal operation attempted on a registry key that has been marked for deletion. (Exception from HRESULT: 0x800703FA.

Stack Trace: at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.CreateRptDoc() 

at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper..ctor() 

at CrystalDecisions.CrystalReports.Engine.ReportDocument.initialize() 

at CrystalDecisions.CrystalReports.Engine.ReportDocument.ctor() 

at Imagemation.Support.Reporting.CrystalReportDocument..ctor() 

at Imagemation.Support.Reporting.NonEmbeddedReportCacher.CreateReport()

How to find application pool used by crystalreportviewers12 in the website used by ClickHome3 web application

1. Expand the website to see the applications under the website

2. Right click in advanced settings, see what crystalreportviewers12  is pointing to in the app pool

3. Open the application pools from IIS and right click to go to advanced settings of .NET (make the below change if necessary) 

    Verify Crystalreportviewers12 application pool settings have 'Managed Pipeline Mode' set to classic mode  

Please refer the following microsoft solution to know more about the cause and the resolution suggested

Snippet from the above solution pasted in this solution here

On a Windows Server 2008-based server, you have a COM+ server application in which the identity is configured to run as a specific user. After working for some time, the application may stop working and keep failing. You have to restart the COM+ application to resolve the issue. You may notice that doing a iis reset would work temporarily but the error comes back again when running crystal reports again.

You'll also see events that resemble the following in the Application log of the computer on which the COM+ application runs:

Log Name:      Application
Source:        Microsoft-Windows-User Profiles Service
Date:          10/26/2009 8:22:13 AM
Event ID:      1530
Task Category: None
Level:         Warning
Keywords:      Classic
User:          SYSTEM
Computer:      SERVERNAME
Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards.  

1 user registry handles leaked from \Registry\User\S-1-5-21-1049297961-3057247634-349289542-1004_Classes:
Process 2428 (\Device\HarddiskVolume1\Windows\System32\dllhost.exe) has opened key \REGISTRY\USER\S-1-5-21-1123456789-3057247634-349289542-1004_CLASSES


As a workaround it may be necessary to modify the default behavior of the User Profile Service. The policy setting 'Do not forcefully unload the user registry at user logoff' counters the default behavior of Vista and newer operating systems. When enabled, the User Profile Service will not forcefully unload the registry, Instead it waits until no other processes are using the user registry before it unloads it. The policy can be found in the group policy editor (gpedit.msc). The policy is located under:

Computer Configuration->Administrative Templates->System-> User Profiles 
 'Do not forcefully unload the user registry at user logoff'

Change the setting from "Not Configured" to "Enabled" which disables the new User Profile Service feature.

'DisableForceUnload' is the value added to the registry.

After implementing the solution, the policy looks like the below screen shot