场景:使用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
中的Catalog项描述中https://msdn.microsoft.com/en-us/library/reportservice2010.catalogitem.aspx从错误消息和调查看来(我的假设),一个名为"属性"的必填字段可能从属性数组中丢失。但是它的价值是多少呢?
请分享你的建议&解决方案,甚至可能是rs.exe的代码替代方案,使用脚本自动将映像部署到SSRS。
我找到了答案。我只是在CreateCatalogItem方法之前添加了一个名为property和name的附加属性,它工作了!
Dim propertyItem As New Microsoft.SqlServer.ReportingServices2010.Property
propertyItem.Name = "Property"
propertyItem.Value = imageName
properties(1) = propertyItem