5
votes

We've a WPF application written in .NET 3.5 using Visual Studio 2010. The solution consists of 8 projects - all compiled in .NET 3.5. The application uses Crystal Report. Target OS is Windows 7.

Recently, the startup project is compiled in .NET 4.0 due to some 3rd party DLL dependency - those DLLs require .NET 4.0. After this change and rebuilding the solution, Crystal Report is throwing exception.

The problem occurs at the constructor of ReportClass.

Exception's message:

The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception.

InnerException's message:

"Retrieving the COM class factory for component with CLSID {4DB2E2BB-78E6-4AEA-BEFB-FDAAB610FD1B} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."

I haven't worked in Crystal Report before. What could be the cause of this problem?

Please note that this problem doesn't occur when compiled as .NET 3.5. Crystal Report is used in the startup project.

5
Do you need to register the Crystal Reports DLL as a COM object?zeencat
I think that you need to build all the projects using .net 4.0, don't know exactly why right now.lex87
@zeencat: not sure what do you mean. i didn't register the DLLs in 3.5.Donotalo
I'm just wondering if this is your issue as I had a similar error with a different dll. This worked for me, may be a complete shot in the dark. msdn.microsoft.com/en-us/library/tzat5yw6(v=vs.71).aspxzeencat
I found a solution [here][1]. This fixes my problem. [1]: stackoverflow.com/a/2892577/68304Donotalo

5 Answers

12
votes

It is likely to be X86/x64 problem.

try to compile your app to target 86 platform.

3
votes

This issue got me for 2 days and its all over the place with very similar answers, however what it ended up being for me was two-fold. I am adding here in hopes it saves someone at least a day..

A lot of post mention this; Go to IIS -> application pools -> click right button on your application pools -> go to advance setting -> Enable 32 bit application = True

Please note that in my case I was building and deploying on a 64bit machine so I set the True to False and it did it. Again, simple enough but not something I thought was related so my mind was blank to it after I made the adjustment.

The other point of interest is to make sure that you do have the CRRuntime_xx.x.x.MSI loaded on Deployment server.

Thank you everyone here for the amazing info at the end of the day it got me through.

2
votes

Go to IIS -> application pools ->click right button on your application pools -> go to advance setting -> Enable 32 bit application = True

0
votes

When you install CR it should install few files (JS,html etc etc) on C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13. Check if this folder exists on your pc. If not, I think you need to copy the folder from program files to this location.

0
votes

These answers got us to the right place but not until we did some troubleshooting. It did end up being a 32/64 bit issue on our local dev machines running Visual Studio 2019 and IIS Express.

In our case the issue was that the setting for "Use the 64 bit version of IIS Express for web sites and projects" had been enabled in visual studio settings. We use the 32 bit version of crystal on our dev machines so we had to Uncheck this box for it to work correctly.

enter image description here