I am generating an XML document from a StringBuilder, basically something like:
string.Format(\"{0}
{1}>
As kind of a late answer:
I've had this problem with SSRS ReportService2005.asmx when uploading a report.
Public Shared Sub CreateReport(ByVal strFileNameAndPath As String, ByVal strReportName As String, ByVal strReportingPath As String, Optional ByVal bOverwrite As Boolean = True)
Dim rs As SSRS_2005_Administration_WithFOA = New SSRS_2005_Administration_WithFOA
rs.Credentials = ReportingServiceInterface.GetMyCredentials(strCredentialsURL)
rs.Timeout = ReportingServiceInterface.iTimeout
rs.Url = ReportingServiceInterface.strReportingServiceURL
rs.UnsafeAuthenticatedConnectionSharing = True
Dim btBuffer As Byte() = Nothing
Dim rsWarnings As Warning() = Nothing
Try
Dim fstrStream As System.IO.FileStream = System.IO.File.OpenRead(strFileNameAndPath)
btBuffer = New Byte(fstrStream.Length - 1) {}
fstrStream.Read(btBuffer, 0, CInt(fstrStream.Length))
fstrStream.Close()
Catch ex As System.IO.IOException
Throw New Exception(ex.Message)
End Try
Try
rsWarnings = rs.CreateReport(strReportName, strReportingPath, bOverwrite, btBuffer, Nothing)
If Not (rsWarnings Is Nothing) Then
Dim warning As Warning
For Each warning In rsWarnings
Log(warning.Message)
Next warning
Else
Log("Report: {0} created successfully with no warnings", strReportName)
End If
Catch ex As System.Web.Services.Protocols.SoapException
Log(ex.Detail.InnerXml.ToString())
Catch ex As Exception
Log("Error at creating report. Invalid server name/timeout?" + vbCrLf + vbCrLf + "Error Description: " + vbCrLf + ex.Message)
Console.ReadKey()
System.Environment.Exit(1)
End Try
End Sub ' End Function CreateThisReport
The problem occurs when you allocate a byte array that is at least 1 byte larger than the RDL (XML) file.
Specifically, I used a C# to vb.net converter, that converted
btBuffer = new byte[fstrStream.Length];
into
btBuffer = New Byte(fstrStream.Length) {}
But because in C# the number denotes the NUMBER OF ELEMENTS in the array, and in VB.NET, that number denotes the UPPER BOUND of the array, I had an excess byte, causing this error.
So the problem's solution is simply:
btBuffer = New Byte(fstrStream.Length - 1) {}