尝试使用rsr使用srrs上传图像时出错 - "输入结构中缺少必填字段属性"

时间:2016-10-13 00:23:09

标签: reporting-services ssrs-2012 rs.exe

场景:使用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 

我在上一行收到的错误是

  

输入结构中缺少必填字段属性。 ---> Microsoft.ReportingServices.Diagnostics.Utilities.MissingElementException:输入结构中缺少必需的字段属性。

要解决问题的属性对象需要哪些参数。

我在MSDN中的CreateCatalogitem方法中找不到相同的内容 https://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010.createcatalogitem(v=sql.120).aspx

也不在MSDN中的目录项描述中

https://msdn.microsoft.com/en-us/library/reportservice2010.catalogitem.aspx

从错误消息和调查中看出它(我的假设)就像一个名为' Property'可能会从属性数组中丢失。但它的价值是什么?

请分享您的建议&解决方案甚至可能是rs.exe的替代代码,可以使用脚本自动将映像部署到ssrs。

1 个答案:

答案 0 :(得分:0)

我找到了答案。我刚刚在CreateCatalogItem方法之前添加了一个名为property和name作为filename的附加属性,并且它工作正常!

Dim propertyItem As New  Microsoft.SqlServer.ReportingServices2010.Property
propertyItem.Name = "Property"
propertyItem.Value =  imageName
properties(1) = propertyItem