我更换了新的电脑,操作系统也从原来32位的windows 2003 R2升级到windows 2008 R2 x64, 由于客户的原因我们的报表部分必须用Crystal Report XI R2来完成,报表在原来的计算机上运行一直没有问题,但是在新的计算机上一直不能正工作,错误如下:
The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception.
Stack Trace:
at CrystalDecisions.CrystalReports.Engine.ReportDocument.CheckForCrystalReportsRuntime()
at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor()
Inner Exception:
An error has occurred while attempting to load the Crystal Reports runtime.
Either the Crystal Reports registry key permissions are insufficient or the Crystal Reports runtime is not installed correctly.
Please install the appropriate Crystal Reports redistributable (CRRedist*.msi) containing the correct version of the Crystal Reports runtime (x86, x64, or Itanium) required. Please go to http://www.businessobjects.com/support for more information.
在我确定我安装了CRRedist2008_x64.msi和CRRedist2008_x86.msi 两个包后问题依旧如此, 其实问题根本就不是CRRedist2008_x64.msi和CRRedist2008_x86.msi 安装与否的问题, 后来我想到了Application Pools,问题果然出在这里, 以我的环境为例解决办法如下:
1. 打开IIS并选择你的Web程序所使用的application pool, 并点击右侧Actions栏中的Advanced Settings
2. 在打开的窗口中设置Enabled 32-Bit Applications为True,
只需要设置这一个属性就可以了,再次运行程序并打开报表,报表可以正常工作了。
另外: