I ran into a strange problem with multi page rendering after a client upgraded the reporting server to 2008 r2.
Background
Basically I'm using the method described here to render the pages of a Reporting Services Report to a bunch of image streams. What happened after the upgrade was that some renderings worked and some didn't. After much gnashing of teeth and hair pulling I realized the difference between those that worked and those that didn't. The ones that didn't work were rendered fresh, with the parameters passed in. Those that did work however had already been executed once and were rerendered with the ExecutionID of the earlier execution passed in.
Workaround
Google was of no use in this case, so I decided to do a work around. It turned out to be quite easy to "prerender" the report using another overloaded version of the Render method, and then use the ExecutionID from that rendering and continue as usual.
if (ExecutionID == null)
{
// Pre rendering
rview.ServerReport.SetParameters(Parameters);
string encoding;
string[] streamids;
Microsoft.Reporting.WebForms.Warning[] warnings;
byte[] bytes = rview.ServerReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
ExecutionID = rview.ServerReport.GetExecutionId();
}
rview.ServerReport.SetExecutionId(ExecutionID);
NameValueCollection urlAccessParameters = new NameValueCollection();
urlAccessParameters.Add("rs:PersistStreams", "True");
// Render first page
Stream s = null;
s = rview.ServerReport.Render(format, deviceInfo, urlAccessParameters, out mimeType, out extension);
streams.Add(s);
urlAccessParameters.Remove("rs:PersistStreams");
urlAccessParameters.Add("rs:GetNextStream", "True");
do
{
s = rview.ServerReport.Render(format, deviceInfo, urlAccessParameters, out mimeType, out extension);
if (s.Length != 0) streams.Add(s);
}
while (s.Length > 0);
It's not the most elegant of solutions but it gets the job done.