[英]Error trying to Upload image using srrs using rs.exe -“The required field Property is missing from the input structure”
場景:使用rs.exe通過srrs上傳圖片(使用代碼而非GUI)
環境:SQL Server 2012,rs.exe,vb.script
'Utility to Publish the Png file ( snippet)
'Sample inputs PublishImageFile("myimagefilename.png", "image/png")
Public Sub PublishImageFile(ByVal imageName As String,ByVal resourceMIME As String)
Try
Dim stream As FileStream = File.OpenRead(filePath + "\" + imageName)
definition = New [Byte](stream.Length - 1) {}
stream.Read(definition, 0, CInt(stream.Length))
stream.Close()
Catch e As IOException
Console.WriteLine(e.Message)
End Try
imageName = imageName.tostring.replace(".png", "")
Console.WriteLine("Attempting to Deploy Resource Name {0}", imageName.tostring)
Dim item As CatalogItem
Dim mimeProperty As New Microsoft.SqlServer.ReportingServices2010.Property
mimeProperty.Name = "MimeType"
mimeProperty.Value = resourceMIME
Dim properties(1) As Microsoft.SqlServer.ReportingServices2010.Property
properties(0) = mimeProperty
Try
item = rs.CreateCatalogItem("Resource", imageName, ReportFolder, True,
definition, properties, warnings) 'Error line
'More code below removed for brevity
我在上面最后一行收到的錯誤是
輸入結構中缺少必填字段Property。 ---> Microsoft.ReportingServices.Diagnostics.Utilities.MissingElementException:輸入結構中缺少必需的字段屬性。
屬性對象中解決此問題所需的必需參數是什么?
我在MSDN https://msdn.microsoft.com/zh-CN/library/reportservice2010.reportingservice2010.createcatalogitem(v=sql.120).aspx中的CreateCatalogitem方法中找不到相同的對象
也沒有在MSDN中的目錄項描述中
https://msdn.microsoft.com/zh-CN/library/reportservice2010.catalogitem.aspx
從錯誤消息和調查中,(我的假設)看起來像一個名為“ Property”的必填字段可能會從屬性數組中丟失。 但是它的價值是什么?
請分享您的建議和解決方案,或者甚至可以替代rs.exe,以使用腳本將映像自動部署到ssrs。
我找到了答案。 我只是在CreateCatalogItem方法之前添加了一個名為property和name作為文件名的附加屬性,它起作用了!
Dim propertyItem As New Microsoft.SqlServer.ReportingServices2010.Property
propertyItem.Name = "Property"
propertyItem.Value = imageName
properties(1) = propertyItem
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.