title: How Do I Resolve Report Deployment Error When Referencing System.Core (4.0) under SSRS 2008R2
body: <p><strong>Preface:</strong> </p>
  
  <p><strong>Development Environment:</strong> Visual Studio 2010 with BIDS + MSSQL 2012 on local box </p>
  
  <p><strong>Production Environment:</strong> MSSQL 2008 R2 For Live Report Server</p>
  
  <p>I am having a problem with deploying a report when referencing System.Core in my report. The error is below.</p>
  
  <blockquote>
    <p>Error while loading code module: ‘System.Core, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089’. Details: Could not
    load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089' or one of its dependencies. This
    assembly is built by a runtime newer than the currently loaded runtime
    and cannot be loaded.</p>
  </blockquote>
  
  <p>I am referencing the System.Core in my report so that I can use the TimeZoneInfo class. I've seen other questions asked about using this class in SSRS and I've not been able to resolve the issue following any of the advice in those questions. </p>
  
  <p><strong>REF</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/2969689/working-with-time-zones-in-ssrs">Working with Time Zones in SSRS</a></p>
  
  <p><a href="https://stackoverflow.com/questions/4995425/ssrs-2k8-custom-dll-file-not-found">SSRS 2k8, custom dll, file not found</a></p>
  
  <p><a href="https://stackoverflow.com/questions/13992373/reporting-services-2012-deploy-error-error-while-loading-code-module">Reporting Services 2012 deploy error: &quot;Error while loading code module&quot;</a></p>
  
  <p>I can reference the System.Core 4.0 and run locally without any issue; however, when I deploy, I get the above error message. To clarify further.. this happens DURING the deploy process, not after deploying and attempting to run the report on the server. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The report RDL xml for CodeModules looks like this: </p>
  
  <pre><code>&lt;CodeModules&gt;
  &lt;CodeModule&gt;System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  </code></pre>
  
  <p>
    </p>
  
  <p>That's about as much "Embedding" as I can tell that it does. It really is just a ref to the assembly from the looks of it. </p>
  
  <p>Assistance would be greatly appreciated. </p>
  
  <p><strong>SOLUTION</strong>
  Since you can't reference 4.0, you can reference 3.5 to gain access to the TimeZoneInfo class. </p>
  
  <p>Step 1. Create a wrapper class for the TimeZoneInfo logic you wish to employ</p>
  
  <p>Step 2. Target 3.5</p>
  
  <p>Step 3. Build a release version and copy it to your [DRIVE]:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies  directory so that your designer can load it</p>
  
  <p>Step 4. Deploy the same assembly to the SQL Server @ the following folder
  [DRIVE]:\Program Files\Microsoft SQL Server\MSRS10.SQL2008\Reporting Services\ReportServer\bin\</p>
  
  <p>Now you can deploy your report. 
  So my errors were the following</p>
  
  <ol>
  <li><p>I didn't reference 3.5</p></li>
  <li><p>I didn't copy to the proper directory for my visual studio instance to pick up the assembly. I had moved my install to a different directory and I didn't put it in the new path. </p></li>
  </ol>
  
  <p><strong>UPDATE</strong>
  If anyone is trying to ref .NET 4.0 ins SSRS 2012 and above and still gets an error, the answer is simple. SSRS 2012 and 2014(?) STILL do not support .NET 4.0</p>
  
  <p><a href="https://stackoverflow.com/questions/10851474/ssrs-2012-custom-code-net-framework-4-0-not-supported">source</a></p>
  
  <p>This one seems to suggest that SSRS 2014 doesn't support it either (I am speechless, MICROSOFT!)
  <a href="https://support.microsoft.com/en-us/kb/2869522" rel="nofollow noreferrer">MS KB</a> </p>