Microsoft KB Archive/919134

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

Article ID: 919134

Article Last Modified on 6/29/2006

-

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 = @&quot;24 9696 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>&quot;;

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(&quot;/SampleReports/Product Catalog&quot;, &quot;IMAGE&quot;, null, JPEG_DEVICE_INFO, null, null, null, out nullStr, out nullStr, out optionalParams, out optionalWarnings, out streamids);

FileStream stream3 = File.Create(@&quot;C:\tmp\report1.JPEG&quot;, 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(&quot;/SampleReports/Product Catalog&quot;, &quot;IMAGE&quot;, streamid, null, JPEG_DEVICE_INFO, null, out nullStr, out nullStr);

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

}

Microsoft Visual Basic code sample
Sub Main Const JPEG_DEVICE_INFO As String = &quot;<DeviceInfo>&quot; & _ &quot;24</ColorDepth>&quot; & _ &quot;</Columns>&quot; & _ &quot;</ColumnSpacing>&quot; & _ &quot;96</DpiX>&quot; & _ &quot;96</DpiY>&quot; & _ &quot;<EndPage>10</EndPage>&quot; & _ &quot;<MarginBottom>1in</MarginBottom>&quot; & _ &quot;<MarginLeft>1in</MarginLeft>&quot; & _ &quot;<MarginRight>1in</MarginRight>&quot; & _ &quot;<MarginTop>1in</MarginTop>&quot; & _ &quot;<OutputFormat>JPEG</OutputFormat>&quot; & _ &quot;<PageHeight>11in</PageHeight>&quot; & _ &quot;<PageWidth>8.5in</PageWidth>&quot; & _ &quot;<StartPage>1</StartPage>&quot; & _ &quot;</DeviceInfo>&quot;

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(&quot;/SampleReports/Product Catalog&quot;, &quot;IMAGE&quot;, Nothing, _          JPEG_DEVICE_INFO, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, streamids)

Dim stream3 As FileStream = File.Create(&quot;C:\tmp\report1.JPEG&quot;, 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(&quot;/SampleReports/Product Catalog&quot;, &quot;IMAGE&quot;, streamid, _           Nothing, JPEG_DEVICE_INFO, Nothing, Nothing, Nothing)

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

Next End Sub

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Keywords: kbtshoot kbprb kbexpertiseadvanced KB919134

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.