Add image in SSRS from a DLL
Hello, I made a DLL which return an Image type :  public static Image GetAssetIcon()  {       return Resource1.alarm;  } Resource1 is a ResourceFile with all my images. Now I want to add this image to a report in SSRS. I add the dll in references of the report. I add an image in the report (external image). And in the image properties, i put the expression : =GlobalTrack.ImageTool.ImageTool.GetAssetIcon() I launch the report and i have this error : "The Value expression used in image ‘Image2’ returned a data type that is not valid" "The value of the ImageData property for the image ‘Image2’ is “”, which is not a valid ImageData" So I cannot put directly an Image file in the report, i have to put an path/url of the image ? thank you
July 29th, 2010 6:05am

Hi djraphi23, The data type for an image control should be byte() array. In this case, you are using Image data type, which is not expected as the image control, that is why the error happens. To solve the issue, please read the image into a byte arrary, and then set it as the source of the image control. Below is a sample code for your reference: Public shared Function GetImageFromByte(Byval selectPictureFile as String) As byte() Dim photo as System.Drawing.Image photo = new System.Drawing.Bitmap(selectPictureFile) Dim ms AS System.IO.MemoryStream = new System.IO.MemoryStream() photo.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg) Dim imagedata as byte() imagedata = ms.GetBuffer() return imagedata End Function If you have any more questions, please feel free to ask. Thanks, Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2010 6:12am

Hey, thank you for your answer ! But i still have questions. I have errors again. Maybe i didn't understand everything. Here what i did : code of my dll : public static byte[] GetEventIcon2() { Image d1 = new Bitmap(Resource1.asset_car); MemoryStream m1 = new MemoryStream(); d1.Save(m1, ImageFormat.Png); byte[] imagedata; imagedata = m1.GetBuffer(); return imagedata; } It's just an example, that's why i have no parameter. then in SSRS, in the image properties i call my dll : =GlobalTrack.ImageTool.ImageTool.GetEventIcon2() But same error ... : The value of the ImageData property for the image ‘Image2’ is “”, which is not a valid ImageData. I checked : GetEventIcon2 returns a not null data. Any ideas ? Tanks.
July 30th, 2010 6:44am

I know this is an old thread but just wondering (hoping) whether djraphi23 ever fixed the prioblem? I converted my "bitmap" (I had actually been using an Image.FromStream(...memorystream object..)) to a Byte() array, and the error message just changed from "...System.Drawing.Bitmap ... is not a valid ImageData" to "...Byte[] ... is not a valid ImageData". Is there anywhere which tells us what IS valid ImageData for an SSRS Image container source? _Ade
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2012 4:48am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics