【发布时间】:2020-12-06 01:07:23
【问题描述】:
我正在开发一个 Windows 窗体应用程序,使用 vb.net 和 microsoft sql server 作为后端。至于报告,我使用的是 microsoft 的 rdlc,这对我来说非常满意,直到我遇到这个明显的问题。
因此,在报告中,我使用了通过本地文件路径加载并作为参数传递的外部图像。我从数据库中检索这些路径并将其传递给报告。这种方法对我有用很长时间,直到它停止工作。现在的情况是,报告中没有加载外部图像(显示的是红十字而不是图像)。就我而言,这个问题与我的 PC 上的权限有关,因为相同的代码和配置以前对我有用,但我无法解决它。我到处搜索,没有尽头,肯定需要帮助。
我的报告代码是:
Try
With Me.ReportViewer1.LocalReport
.DataSources.Clear()
.ReportPath = Application.StartupPath & "\RptArticle.rdlc"
.EnableExternalImages = True
Dim imagepathstring As String = System.IO.Path.Combine(folder & "\ArticlePics", imagepath)
Dim imgparameter As New ReportParameter
imgparameter = New ReportParameter("ImagePath", "file://" & imagepathstring, True)
.SetParameters(imgparameter)
Dim barpathstring As String = System.IO.Path.Combine(folder & "\BarCode", barpath)
Dim barcode As New ReportParameter("Barcode", "file://" & barpathstring, True)
.SetParameters(barcode)
.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DSArticleAccessory", Accdt))
.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DSArticleSize", AccSdt))
.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DSArticleColour", AccCdt))
.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DSArticleColour", AccCdt))
.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DSArticle", dt))
End With
Me.ReportViewer1.ZoomMode = ZoomMode.PageWidth
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Me.ReportViewer1.RefreshReport()
当我加载报告时,输出是:
警告:如果将报表发布到没有 UnattendedExecutionAccount 的报表服务器或目标图像未启用匿名访问,则不会显示具有外部 URL 引用的图像。 (rsWarningFetchingExternalImages) 警告:图像“Image1”的 MIMEType 属性值是“application/octet-stream”,它不是有效的 MIMEType。 (rsInvalidMIMEType) 警告:图像“Image1”的 ImageData 属性值为“”,这不是有效的 ImageData。 (rsInvalidExternalImageProperty) 警告:图像“Image2”的 MIMEType 属性值为“application/octet-stream”,它不是有效的 MIMEType。 (rsInvalidMIMEType) 警告:图像“Image2”的 ImageData 属性值为“”,这不是有效的 ImageData。 (rsInvalidExternalImageProperty) 线程 0x3948 已退出,代码为 0 (0x0)。
【问题讨论】:
标签: vb.net visual-studio rdlc