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

Posted: 05/15/2013

If you’ve made you’re way here you’ve received the “The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception. at CrystalDecisions.CrystalReports.Engine.ReportDocument..ctor() “ exception.

In my experience, there are a few things that can cause this, you will want to look at this things:

  1. Make sure that your site or application is referencing the correct Crystal Reports assemblies. There are times when you can leave one off and this can be thrown.
  2. Make sure that the Crystal Reports runtimes are installed. It is VERY important that you have the correct runtime installed for you application. For instance, if you install the 32-bit runtime you will want to force your application into x86 (32-bit) mode. If you have the 64-bit runtime installed make sure it targets x64.
  3. In ASP.NET, I just encountered this error because the web site was running in the 64-bit app pool and it was trying to use the 32-bit crystal reports runtime. This will work actually, but you have to tell web-site (in IIS7) to allow 32-bit apps in it’s advanced properties. If you do not allow 32-bit apps, it will fail because it won’t find the references it needs. By default, the web-site will disallow 32-bit apps (at least it’s by default on the server I’m using).

Luckly, I had one web-site working on this server and one not… so I knew it was capable of working which helped narrow down what I was looking for.