title: Crystal Reports on Windows Server 2012 class not registered error
body: <p>This question has been asked before:</p>
  
  <p><a href="https://stackoverflow.com/questions/12195399/crystal-report-in-net-framework-4-0">Crystal Report in .NET Framework 4.0</a></p>
  
  <p>and </p>
  
  <p><a href="https://stackoverflow.com/questions/1036856/retrieving-the-com-class-factory-for-component-with-clsid-xxxx-failed-due-to-t/2892577#2892577">Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154</a></p>
  
  <p>But I am (I think, running into a slightly different problem, or at least I hope so).</p>
  
  <p>I have a Solution in Visual Studio 2017 that contains projects for 16 separate websites. So, config changes like switching from "Any CPU" to "x86" are not trivial. I made one stab at doing this and failed so miserably that I completely broke the site I am trying to fix!</p>
  
  <p>In my attempts to understand the problem I have built the site on my dev box (Windows 10, 64bit) and run it under localhost and everything works. In particular, the call to <code>New ReportDocument()</code> works and I get the expected PDF of a Crystal Report.</p>
  
  <p>However, when I deploy the project to my dev server running Windows Server 2012 the same attempt to view a generated PDF file fails.</p>
  
  <p>When I use a <code>Try-Catch</code> around the offending call to 'New ReportDocument()<code>, the</code>exception` is:</p>
  
  <pre><code> $exception {"The type initializer for
   'CrystalDecisions.CrystalReports.Engine.ReportDocument'
       threw an exception."}  System.TypeInitializationException
  </code></pre>
  
  <p>And the <code>InnerException</code> is:</p>
  
  <pre><code>InnerException {"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))."}  System.Exception {System.Runtime.InteropServices.COMException}
  </code></pre>
  
  <p>I also found a link to: <a href="https://docs.microsoft.com/en-us/dotnet/framework/tools/regasm-exe-assembly-registration-tool" rel="nofollow noreferrer">regasm</a> and generated .reg files on my machine to then load on my dev server, but this had no effect on my error.</p>
  
  <p><strong>Finally, please note</strong> that this is likely a product of upgrading from the Crystal Reports that is compatible with Visual Studio 2015 to the one for Visual Studio 2017.  I now truly regret making that change but I am not sure if it can be undone safely.</p>
  
  <p>What am I missing in moving my project from my dev machine to my dev server?</p>
  
  <hr>
  
  <h2><strong>Update</strong></h2>
  
  <p>I still have not found a solution...</p>
  
  <p>I did find this <a href="https://forums.iis.net/t/1183589.aspx" rel="nofollow noreferrer">post</a> in forums.iis.net. I am working through it's hints but have not finished and thought I would update my question here in case it helps someone else.</p>
  
  <p>Still looking for some suggestions.</p>