Error message when you call the ReportingService.RenderStream method in SQL Server 2000 Reporting Services: "An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in system.web.services.dll" (919134)



The information in this article applies to:

  • Microsoft SQL Server 2000 Reporting Services Service Pack 2

SYMPTOMS

When you call the ReportingService.RenderStream method in an application, you may receive the following error message:
An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in system.web.services.dll

Additional information: System.Web.Services.Protocols.SoapException: The stream cannot be found. The stream identifier that is provided to an operation cannot be located in the report server database. ---> Microsoft.ReportingServices.Diagnostics.Utilities.StreamNotFoundException: The stream cannot be found. The stream identifier that is provided to an operation cannot be located in the report server database.
at Microsoft.ReportingServices.Library.RSService.GetReportImage(ClientRequest session, CatalogItemContext itemContext)

at Microsoft.ReportingServices.WebServer.ReportingService.RenderStream(String Report, String Format, String StreamID, String HistoryID, String DeviceInfo, ParameterValue[] Parameters, Byte[]& Result, String& Encoding, String& MimeType)

--- End of inner exception stack trace ---

at Microsoft.ReportingServices.WebServer.ReportingService.RenderStream(String Report, String Format, String StreamID, String HistoryID, String DeviceInfo, ParameterValue[] Parameters, Byte[]& Result, String& Encoding, String& MimeType)
This problem occurs when the following conditions are true:
  • You render a Microsoft SQL Server 2000 Reporting Services report to a multistream image file. For example, you render a Reporting Services report to a .bmp file or to a .jpg file.
  • No device-specific content is passed to the ReportingService.RenderStream method.
Note This problem does not occur if you render a Reporting Services report to a .tif file. The reason is that a .tif file is not rendered to a multistream image file.

CAUSE

This problem occurs because the device-specific content is required by the ReportingService.RenderStream method when you render a Reporting Services report to a multistream image file.

WORKAROUND

To work around this problem, pass the device-specific content to the ReportingService.RenderStream method. Pass the same device-specific content that you pass to the ReportingService.Render method. The ReportingService.Render method generates the stream identifiers that are passed to the ReportingService.RenderStream method.

Notes
  • You must install Microsoft SQL Server 2000 Reporting Services Service Pack 2 (SP2) before you use this workaround.
  • This workaround does not apply to the situation in which you render a Reporting Services report to a .tif file.
The following code samples demonstrate this workaround.

Microsoft Visual C# code sample

static void Main(string[] args)
{
    string JPEG_DEVICE_INFO = @"<DeviceInfo><ColorDepth>24</ColorDepth><Columns></Columns>
                                <ColumnSpacing></ColumnSpacing><DpiX>96</DpiX><DpiY>96</DpiY>
                                <EndPage>10</EndPage><MarginBottom>1in</MarginBottom>
                                <MarginLeft>1in</MarginLeft><MarginRight>1in</MarginRight>
                                <MarginTop>1in</MarginTop><OutputFormat>JPEG</OutputFormat>
                                <PageHeight>11in</PageHeight><PageWidth>8.5in</PageWidth>
                                <StartPage>1</StartPage></DeviceInfo>";

   string[] streamids;
   ReportingService rs = new ReportingService();
   rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

   byte[] result;
   string nullStr = null;
   ParameterValue[] optionalParams = null;
   Warning[] optionalWarnings = null;

   result = rs.Render("/SampleReports/Product Catalog", "IMAGE", null, JPEG_DEVICE_INFO, null, null, null, out nullStr, out nullStr, out optionalParams, out optionalWarnings, out streamids);

   FileStream stream3 = File.Create(@"C:\tmp\report1.JPEG", result.Length);
   stream3.Write(result, 0, result.Length);
   stream3.Close();
   byte[] result1;

   //Loop through streams and add to filestream.
   foreach (string streamid in streamids)
   {
      //Note The device-specific content (JPEG_DEVICE_INFO) is passed to the renderstream method to call the method successfully.
      result1 = rs.RenderStream("/SampleReports/Product Catalog", "IMAGE", streamid, null, JPEG_DEVICE_INFO, null, out nullStr, out nullStr);

      //Write out the stream in a new file.
      FileStream stream4 = File.Create(@"C:\tmp\" + streamid + ".JPEG", result1.Length);
      stream4.Write(result1, 0, result1.Length);
      stream4.Close();
   }

}

Microsoft Visual Basic code sample

Sub Main()
        Const JPEG_DEVICE_INFO As String = "<DeviceInfo>" & _
                   "<ColorDepth>24</ColorDepth>" & _
                   "<Columns></Columns>" & _
                   "<ColumnSpacing></ColumnSpacing>" & _
                   "<DpiX>96</DpiX>" & _
                   "<DpiY>96</DpiY>" & _
                   "<EndPage>10</EndPage>" & _
                   "<MarginBottom>1in</MarginBottom>" & _
                   "<MarginLeft>1in</MarginLeft>" & _
                   "<MarginRight>1in</MarginRight>" & _
                   "<MarginTop>1in</MarginTop>" & _
                   "<OutputFormat>JPEG</OutputFormat>" & _
                   "<PageHeight>11in</PageHeight>" & _
                   "<PageWidth>8.5in</PageWidth>" & _
                   "<StartPage>1</StartPage>" & _
                   "</DeviceInfo>"

        Dim streamids As String(), streamid As String
        Dim rs As New ReportingService
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials

        Dim result() As Byte
        result = rs.Render("/SampleReports/Product Catalog", "IMAGE", Nothing, _
           JPEG_DEVICE_INFO, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, streamids)

        Dim stream3 As FileStream = File.Create("C:\tmp\report1.JPEG", result.Length)
        stream3.Write(result, 0, result.Length)
        stream3.Close()

        Dim result1() As Byte

        'Loop through streams and add to filestream.
        For Each streamid In streamids
            'Note The device-specific content (JPEG_DEVICE_INFO) is passed to the renderstream method to call the method successfully.
            result1 = rs.RenderStream("/SampleReports/Product Catalog", "IMAGE", streamid, _
            Nothing, JPEG_DEVICE_INFO, Nothing, Nothing, Nothing)

            'Write out the stream in a new file.
            Dim stream4 As FileStream = File.Create("C:\tmp\" & streamid & ".JPEG", result1.Length)
            stream4.Write(result1, 0, result1.Length)
            stream4.Close()

        Next
End Sub

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Modification Type:MajorLast Reviewed:6/29/2006
Keywords:kbExpertiseAdvanced kbtshoot kbprb KB919134 kbAudDeveloper kbAudITPRO