locked
SSRS Web Reference - Unable to load one or more of the requested types. RRS feed

  • Question

  • Hi,

    I am having issues with SSRS web service on the server project on light switch. I have got the code working on a console app, but the light switch project will not build with the web reference added. It fails shoing this error. 



    I have read the forum post below (link 1), but the marked answer does not seem to answer the question, just explains why it happens. I understand that the web references run under .NET 2.0 and I assume this is the root of the issue as the server project is .NET 4.0, however when I add the same reference to the service reference section I get a different set of methods etc... So I have managed to find some code (Link 2) which uses the ReportExecutionServiceSoapClient() class instead of the ReportExecutionService() so that I can use the service reference instead of web reference. However when I use this it will not authenticate and I don't know why. See the code I am using below (Code 1)... It fails on the rs.LoadReport method. 

    I would greatly appreciate some help on this...

    Link 1:
    http://social.msdn.microsoft.com/Forums/en-US/96819d28-e64a-4c85-970d-1fc2044a289c/compile-error-unable-to-load-one-or-more-of-the-requested-types-retrieve-loaderexceptions-property

    Link 2: 
    http://ikbalouch.wordpress.com/2010/04/27/calling-sql2008-reporting-server-webservice-programmaticall/

    Code 1:

      Public Sub PrintReport()
    
            Dim rs As New SSRSService.ReportExecutionServiceSoapClient
    		rs.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultCredentials
            rs.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation
           
            Dim execInfo As New ExecutionInfo
            Dim trusteduserHeader As New TrustedUserHeader
            Dim execHeader As New ExecutionHeader
            Dim serviceInfo As New ServerInfoHeader
    
            'Render Arguments
            Dim result As Byte() = Nothing
            Dim reportPath As String = "/SAO - Leighton Buzzard/FAI - Goods In/Puchasing Metrics/Goods Inwards Inspection Bench"
            Dim format As String = "PDF"
            Dim historyID As String = Nothing
            Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
    
            Try
                execHeader = rs.LoadReport(trusteduserHeader, reportPath, historyID, serviceInfo, execInfo)
    			'FAILS HERE ^^^^^
            Catch e As SoapException
                Debug.WriteLine(e.Message)
                Debug.WriteLine(e.Detail.OuterXml)
            End Try
    
            Dim credentials As DataSourceCredentials() = Nothing
            Dim showHideToggle As String = Nothing
            Dim encoding As String = Nothing
            Dim mimeType As String = Nothing
            Dim extension As String = Nothing
            Dim warnings As Warning() = Nothing
            Dim reportHistoryParameters As ParameterValue() = Nothing
            Dim streamIDs As String() = Nothing
    
            Try
                rs.Render(execHeader, trusteduserHeader, format, devInfo, result, extension, mimeType, encoding, warnings, streamIDs)
            Catch e As SoapException
                '      Console.WriteLine(e.Detail.OuterXml)
            End Try
    		
            Try
                Dim path As [String] = "C:\test\report.pdf"
                Dim stream As FileStream = File.Create(path, result.Length)
                '   Console.WriteLine("File created.")
                stream.Write(result, 0, result.Length)
                '   Console.WriteLine("Result written to the file.")
                stream.Close()
                printPDF(path)
            Catch e As Exception
                'Console.WriteLine(e.Message)
            End Try
    
        End Sub 


    Tuesday, April 29, 2014 12:34 PM

Answers

  • Hi,

    According to your description above, I don't think there is something wrong with the code below.

     execHeader = rs.LoadReport(trusteduserHeader, reportPath, historyID, out serviceInfo, out execInfo); 

    For this issue, it's also recommended to get help form SQL Server Reporting Services, Power View, SSRS experts can give more precise troubleshooting.

    hope it helps.

    Regards


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Angie Xu Wednesday, May 7, 2014 5:42 AM
    Friday, May 2, 2014 5:58 AM