Preface:
Development Environment: Visual Studio 2010 with BIDS + MSSQL 2012 on local box
Production Environment: MSSQL 2008 R2 For Live Report Server
I am having a problem with deploying a report when referencing System.Core in my report. The error is below.
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.
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.
REF
Working with Time Zones in SSRS
SSRS 2k8, custom dll, file not found
Reporting Services 2012 deploy error: "Error while loading code module"
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.
EDIT
The report RDL xml for CodeModules looks like this:
<CodeModules>
<CodeModule>System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
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.
Assistance would be greatly appreciated.
SOLUTION Since you can't reference 4.0, you can reference 3.5 to gain access to the TimeZoneInfo class.
Step 1. Create a wrapper class for the TimeZoneInfo logic you wish to employ
Step 2. Target 3.5
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
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\
Now you can deploy your report. So my errors were the following
I didn't reference 3.5
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.
UPDATE 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
This one seems to suggest that SSRS 2014 doesn't support it either (I am speechless, MICROSOFT!) MS KB
As requested:
SOLUTION
Since you can't reference 4.0, you can reference 3.5 to gain access to the TimeZoneInfo class.
Step 1. Create a wrapper class for the TimeZoneInfo logic you wish to employ
Step 2. Target 3.5
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
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\
Now you can deploy your report. So my errors were the following
I didn't reference 3.5
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.