none
Deploy errors when deploying reports having external assembly references RRS feed

  • Question

  • Hi,

    I’m trying to move our Reporting Services files into the new BI Report Server Project in VS2010 / Data Tools 2012. This project type seems to work well  - except that I’m having problems using the deploy functionality for reports with references to external .Net assemblies. No matter how I try, deploy function results in errors even though I can manually upload my reports (using Report Manager web interface) and successfully execute them.

    Using a simple test report, containing nothing else than a textbox with the following expression:

    =TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"))

    and a reference to a version 3.5 System.Core dll (set in report properties->References) like this:

    System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

    deploying this report results in an error “The definition of the report '/Report1' is invalid.”. Preview (using .Net 4) doesn’t work as “[BC30560] ‘TimeZoneInfo’ is ambiguous in the namespace ‘System’”. However, a manual upload via Report Manager yields no errors and works fine.

     If I Remove the reference to System.Core I get another deploy error “The Value expression for the textrun ‘Textbox1.Paragraphs[0].TextRuns[0]’ contains an error: [BC30451] Name 'TimeZoneInfo' is not declared” which I guess makes sense since TimeZoneInfo is not part of .net 2.0 which seems to be used by the Report Server. But, removal of the this System.Core reference makes preview in SSRS work again.

    It seems like the deploy functionality if SSRS/Data Tools doesn’t consider the external report references, but preview does. Has anyone worked around this? I’d really like to use the deploy functionality. Also, using SQL Server 2012, is it not possible to have report server using a later CLR version than 2.0 for expressions and custom code?

    Microsoft Visual Studio 2010 Version 10.0.40219.1 SP1Rel
    SQL Server 2012
    Microsoft SQL Server Data Tools   10.3.20225.0
    Microsoft SQL Server Reporting Services Designers  Version 11.0.2100.60

    Thanks
    Monday, September 3, 2012 3:46 PM

All replies

  • Hi Ma6s,

    I'm facing the same problem here. Deployment worked fine in visual Studio 2008, but deployed them locally. Now, using SQL server 2012, we installed a dedicated Report server. I tried to replace the system.core refrence to 4.0 and the report runs fine locally. But then the following error occures when I deploy to the RS:

    Error 2 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. The system cannot find the file specified.  0 0 

    Did you find any solutions to the problem?

    Thanks

    Friday, January 4, 2013 9:23 AM
  • Hi,

    I'm having the exact same problems.

    I even tried copying the System.Core 4.0 DLL to %PROGRAMFILES%\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin. In that case, I get the following error when attempting to deploy the report to my local report server instance:

    Error 1 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.

    If anyone has any idea how to resolve this, please help.

    Thanks!

    Thursday, May 23, 2013 2:21 PM
  • I am faced with a similar issue.  Specically, using the System.TimeZoneInfo class is important, because SQL Server T-SQL supports timezone offset calculations, but nottimezone calculations that include automatically adjusting for daylight savings time.

    I filled this MS connect bug:  https://connect.microsoft.com/SQLServer/feedback/details/789592/ssdt-bi-for-vs-2012-incompatible-with-net-3-5-system-core-types

    Wednesday, June 5, 2013 9:58 PM
  • Hi,

    We have also just got this issue when deploying a SQL 2012 RS report which references a custom assembly:

    "Error 1 Error while loading code module: ‘<module name>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Details: Could not load file or assembly '‘<module name>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded"

    Any assistance greatly appreciated.

    Friday, February 7, 2014 6:22 PM
  • Ok found the answer to the "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded" error. RS still does not support .Net framework higher than 3.5 - just rebuilt the custom dll in 3.5 and deployed ok.
    • Proposed as answer by MattAmigo Friday, February 7, 2014 8:23 PM
    Friday, February 7, 2014 8:23 PM
  • I know this post is very old but the issue actually STILL exists (SQL Server 2014 and VS2015)! So I'll post my solution as reference for other people that might have the same issue.

    SSDT seems to include the System.Core 4.0 assembly per default during design time, although this is not supported by SSRS itself. So when explicitly adding the System.Core 3.5 reference to the report we have the TimeZoneInfo class available by both referenced assemblies. When the reference of System.Core 3.5 is removed from the report the server has no reference to TimeZoneInfo class.

    The common solution to this is to create a litte custom 'wrapper' assembly which exposes the necessary methods from the TimeZoneInfo class, and to deploy it to both dev and target SSRS server. Unfortunately deploying custom assemblies is not possible in my case.

    So I wrote a custom code snippet that can just be embedded into the report. It uses Reflection to load the 3.5 assembly during runtime and invokes the necessary Methods. The invoke calls are mapped to Delegates in order to prevent slow execution times from Invoke call. I really had a hard time to do this in VB instead of C# :)

    ' Use Reflection in order to handle 'ambiguous' TimezoneInfo type when designing and deploying report while including System.Core assembly.
    ' SSRS needs the reference of System.Core 3.5 assembly, while SSDT designer obviously includes System.Core 4.0 which causes ambigious class reference on design time.
    
    Private Interface ITimeZoneInfo
    	Function ConvertTimeFromUtc(ByVal utcDateTime as DateTime, ByVal timeZoneId as String) as DateTime
    	Function ConvertTimeToUtc(ByVal localDateTime as DateTime, ByVal timeZoneId as String) as DateTime
    End Interface
    
    ' Define a 'wrapper' class of generic type in order to be able to create strong typed Delegate Functions without specifying TimeZoneInfo class
    ' that would fail during compile time. 
    
    Private Class TimeZoneInfo(Of t) 
    	Implements ITimeZoneInfo
    
    	delegate function FindSystemTimeZoneByIdDelegate(ByVal s As String) as t
    	delegate function ConvertTimeFromUtcDelegate(ByVal d As DateTime, ByVal tz As t) as DateTime
    	delegate function ConvertTimeToUtcDelegate(ByVal d As DateTime, ByVal tz As t) as DateTime
    	
    	Dim _findTz as FindSystemTimeZoneByIdDelegate
    	Dim _fromUtc as ConvertTimeFromUtcDelegate
    	Dim _toUtc as ConvertTimeToUtcDelegate
    
    	Public Sub New()
    		' Create and store Delegates in order to avoid slow calls to MethodInfo.Invoke() calls
    		_findTz = CType([Delegate].CreateDelegate(GetType(FindSystemTimeZoneByIdDelegate), GetType(t).GetMethod("FindSystemTimeZoneById")), FindSystemTimeZoneByIdDelegate)
    		_fromUtc = [Delegate].CreateDelegate(GetType(ConvertTimeFromUtcDelegate), GetType(t).GetMethod("ConvertTimeFromUtc"))
    		_toUtc = [Delegate].CreateDelegate(GetType(ConvertTimeToUtcDelegate), GetType(t).GetMethod("ConvertTimeToUtc", New Type() {GetType(DateTime), GetType(t)}))
    	End Sub
    
    	Public Function ConvertTimeFromUtc(ByVal utcDateTime as DateTime, ByVal timeZoneId as String) as DateTime Implements ITimeZoneInfo.ConvertTimeFromUtc
    		return _fromUtc(utcDateTime, _findTz(timeZoneId))
    	End Function
    	
    	Public Function ConvertTimeToUtc(ByVal localDateTime as DateTime, ByVal timeZoneId as String) as DateTime Implements ITimeZoneInfo.ConvertTimeToUtc
    		return _toUtc(localDateTime, _findTz(timeZoneId))
    	End Function
    End Class
    
    dim _timeZoneInfo as ITimeZoneInfo
    dim _initialized as boolean
    
    private function Init()
    	if _initialized = false then
    		' Dynamically load System.Core assembly with version 3.5, which works on both SSTS and SSRS side. Get TimeZoneInfo Type from assembly, and create an instance 
    		' of TimeZoneInfo generic type class by providing the original TimeZoneInfo class.
    		dim a as System.Reflection.Assembly = System.Reflection.Assembly.Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
    		dim tzi as Type = a.GetType("System.TimeZoneInfo")
    		dim gt as Type = GetType(TimeZoneInfo(Of)).MakeGenericType(tzi)
    		_timeZoneInfo = Activator.CreateInstance(gt, new object(){})
    		_initialized = true
    	end if
    end function
    
    public function FromUtc(utc as object) as object
    	If utc Is Nothing
    		return Nothing
    	ElseIf TypeOf utc Is DateTime
    		Init()
    		return _timeZoneInfo.ConvertTimeFromUtc(utc, Report.Parameters!prm_TimeZone.Value)
    	End If
    	return Nothing
    end function
    
    public function ToUtc(local as object) as object
    	If local Is Nothing
    		return Nothing
    	ElseIf TypeOf local Is DateTime
    		Init()
    		return _timeZoneInfo.ConvertTimetoUtc(local, Report.Parameters!prm_TimeZone.Value)
    	End If
    	return Nothing
    end function

    Wednesday, April 13, 2016 4:02 PM
  • after going thru all this trouble... I thought this was genius solution..

    Allow users to select the output "TimeZone"... 

    Then convert the time to selected TimeZone..

    =TimeZoneInfo.ConvertTimeFromUtc(Fields!AuditorReportDate.Value, TimeZoneInfo.FindSystemTimeZoneById(Parameters!OutputTimeZone.Value))

    Only to have it work perfectly locally but not on the SSRS server.

    Are you KIDDING me. Any other answers other than building a wrapper assembly?

    Wednesday, February 15, 2017 7:30 PM
  • new to SSRS and VB world, encountered this issue and attempting to use proposed code.  Getting error in textbox calling function.  

    Warning 1 [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Date.Paragraphs[0].TextRuns[0]’ contains an error: Value cannot be null.  Parameter name: method

    "Parameter name: method" in error message is confusing.  Not sure what might cause this.  Any ideas?  Thanks.



    • Edited by ak912 Thursday, July 20, 2017 2:02 PM
    Thursday, July 20, 2017 2:02 PM
  • Thanks, the wrapper got my timezoneinfo code deployed and didn't require any install on the server. Worked well. 
    Tuesday, November 27, 2018 11:29 PM