2012-12-12 20 views
2

我有一個在Visual Studio 2010中使用VB.NET,SSRS和SQL Server 2008 R2開發的ASP.NET 4.0應用程序。該應用程序中有一個頁面,用於收集用戶的輸入,它用作參數從SQL Server數據庫獲取數據,然後將其放入SSRS報告中,然後將其轉換爲PDF文件。這一切在我的開發機器上都能正常工作,但在服務器上出現錯誤,特別是當它試圖對ServerReport引擎執行任何操作時。除了能夠從我的開發機器打開報告外,我還可以直接在報告管理器中打開報告。當我嘗試從生產機器打開報告時,報告沒有打開,錯誤由頁面左下角的黃色三角表示,當雙擊打開此消息時,該三角形顯示。嘗試訪問生產計算機上的報表服務器但未在開發計算機上時獲取「未知錯誤」

`Webpage error details 

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; CMDTDF; BRI/1; .NET4.0C; InfoPath.3; .NET4.0E) 
Timestamp: Wed, 12 Dec 2012 20:03:54 UTC 

Message: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500 
ScriptResource.axd                Line: 2 
Code: 0                  Char: 74741 
URI: http://intranet/webapps/RecordedOnlyIncidents/ScriptResource.axd?d=GnweTchBv7S3iPh-J2y96yey3C3_pzddkEeS0GIM0GHz6A1wrAToLVysD0C0nmS_sugidnIpUa9dt3MXUvPZgTV3kdSrhNnjjikolQ4t_qbyruxeky4MDgxR-klgMjZP0&t=ffffffffbad362a4` 

所述的生產機器運行的是Windows 2003和IIS 6 開發機運行微軟Windows 7和IIS 7 這兩個機器的訪問SQL Server和報表服務器是安裝在VMware虛擬服務器上運行Windows Server 2008 R2標準。

我查看了應用程序運行的服務器上的事件日誌,但沒有發現有關實際錯誤的線索。我還查看了位於C:\ Program Files \ Microsoft SQL Server \ MSRS10_50.MSSQLSERVER \ Reporting Services \ LogFiles的報表服務器上的日誌文件。當我在我的開發機器上運行應用程序時,報告打開,並且以下行添加到日誌「library!ReportServer_0-30!1614!11/27/2012-20:18:54 :: i INFO:RenderForNewSession('/RecordedOnlyIncidents /報告/ AllIncidentsWithParameters')」。如果我然後更改開發計算機上的代碼指定一個無效路徑,以便發生錯誤,那麼仍然有一個指定錯誤的條目。 「Reporter_0-30!1674!11/27/2012-18:30:19 :: e錯誤:拋出Microsoft.ReportingServices.Diagnostics.Utilities.InvalidItemPathException:,Microsoft.ReportingServices.Diagnostics.Utilities.InvalidItemPathException:路徑/ReportViewer.aspx?/RecordedOnlyIncidents/Reports/AllIncidentsWithParameters'的項目無效,完整路徑必須小於260個字符;其他限制適用。如果報告服務器處於純模式,則路徑必須以斜槓開始。」但是,如果我在服務器上運行應用程序,並且出現錯誤,則日誌中沒有條目,因此我假設甚至沒有嘗試訪問報告服務器。

我的代碼如下:

`Dim r = New ServerReport 
r.ReportServerUrl = New Uri("http://vm-intranet/ReportServer") 
r.ReportPath = "/RecordedOnlyIncidents/Reports/AllIncidentsWithParameters" 
Dim EmployeeNumber As String = IIf(txtSearchEmployeeNumber.Text = "", Nothing, txtSearchEmployeeNumber.Text) 
Dim IncidentType As String = IIf(ddlSearchIncidentType.SelectedItem.Text = "", Nothing, ddlSearchIncidentType.SelectedItem.Text) 
Dim BeginningDate As String = IIf(txtBeginningDate.Text = "", Nothing, txtBeginningDate.Text) 
Dim EndingDate As String = IIf(txtEndingDate.Text = "", Nothing, txtEndingDate.Text) 
Dim parmEmpNumEmployeeNumber As New ReportParameter("EmployeeNumber", EmployeeNumber) 
Dim parmIncidentType As New ReportParameter("IncidentType", IncidentType) 
Dim parmBeginningDate As New ReportParameter("BeginningDate", BeginningDate) 
Dim parmEndingDate As New ReportParameter("EndingDate", EndingDate) 
Dim parameters(3) As ReportParameter 
parameters(0) = parmEmpNumEmployeeNumber 
parameters(1) = parmIncidentType 
parameters(2) = parmBeginningDate 
parameters(3) = parmEndingDate 
r.SetParameters(parameters) 
Dim warnings As Warning() = Nothing 
Dim streamids As String() = Nothing 
Dim mimeType As String = Nothing 
Dim encoding As String = Nothing 
Dim extension As String = Nothing 
Dim reportOutput As Byte() = r.Render("PDF", Nothing, mimeType, encoding, extension, streamids, warnings) 
Dim path As String = System.AppDomain.CurrentDomain.BaseDirectory 
Dim stream As New IO.FileStream(path & "/MyReport.pdf", IO.FileMode.Create) 
IO.FileMode.Create) 
stream.Write(reportOutput, 0, reportOutput.Length) 
stream.Close() 
Dim Script As String = "<script type='text/javascript'> win=window.open("""",""_blank"",""resizable=Yes,height=600"");win=win.document;win.write(""<style>body{margin:0px;}</style>"");win.write(""<title> Incidents Report</title>"");win.write(""<iframe src='MyReport.pdf' style='width:100%;height:100%;'></iframe>"");</script>" 
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "OpenReport", Script, False)` 

上線時出現錯誤:

`r.SetParameters(parameters)` 

不過我也用一個報告,沒有采取參數,然後發生在錯誤嘗試該行:

`Dim reportOutput As Byte() = r.Render("PDF", Nothing, mimeType, encoding, extension, streamids, warnings)` 

任何建議將不勝感激。

回答

0

如果您沒有傳遞正確的擴展參數。還要檢查您是否擁有網站根文件夾的寫入權限。

我們做了一些與此類似:

ReportViewer1.ServerReport.Render(exportFormat, Nothing, mimeType, encoding, exportFormat, streams, warnings) 
+0

歡迎來到SO。希望看到你在學習系統時貢獻更多。 – davidethell

+0

你好,非常感謝你的回覆。該應用設置爲在我指定的帳戶下運行,並且該帳戶和我的帳戶都擁有該網站的權限。我不認爲這是一個權限問題,因爲該應用程序在開發和生產機器上運行。唯一的問題是試圖在生產機器上打開報告。 – user1788680

+0

關於你的其他建議說實話,我複製了我在網上找到的代碼,並且我遇到的所有示例都將擴展參數設置爲無。我還有什麼可以放在那裏的?如果這是問題,它也不會發生在開發機器上嗎? – user1788680

0

我找到了答案,報表查看器的錯誤版本,安裝在服務器上。

相關問題