问题
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.
回答1:
It is likely to be X86/x64 problem.
try to compile your app to target 86 platform.
回答2:
Go to IIS -> application pools ->click right button on your application pools -> go to advance setting -> Enable 32 bit application = True
回答3:
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.
回答4:
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.
来源:https://stackoverflow.com/questions/12195399/crystal-report-in-net-framework-4-0