I'm trying to display an image that has been returned from an external assembly, but am having no luck at all.
Essentially, I have a utility class that goes to a resource file and pulls out a JPG and returns it. I have set the value property of the image control on the report to hit this assembly, like so :
= Code.getLogo()
where the function Code.getLogo() actually interfaces with the utility class.
I have tried several variations of this code. I have returned the image as an Image object, a JPG, a TIFF and a BMP. I've also been adventurous and tried converting it to a base64 string before it gets to the report and then having the report convert it back to bytes before shoving it into the image value. Consistently I get this error :
The value expression used in image ‘logo’ returned a data type that is not valid.
A reply to a similar post on the www.sqlreportingservices.net site suggested that it's a Code Access Security issue, but I'm sure it's not, because when I dump my base64 string into a text field, it fills half the page.
What is this control expecting? Any thoughts?
Have you tried setting Image.Source to Database? If you specify Embedded, the value of Value is the resource's name embedded in the report, not the image's binary data. If you specify External, it is expecting a URL path to the image. Specifying Database indicates that the image contents is coming from a database field and Value is then the image's binary data. It's not actually coming from the database in your case, but Image should interpret the Value properly all the same.|||Yes, I did indeed have it set to Embedded.
When I set to Database, I have a whole new set of errors, but they seem more straightforward. I'll fiddle with it for a while and see what I can come up with.
Got me over a big hurdle. Thanks.
|||Next you'll want to make sure your MIMEType is set correctly. If you're returning JPEG data, you want to set your MIMEType to image/jpeg. If you have a mismatch, it will try to interpret your JPEG as a BMP (i.e. MIMEType = image/bmp) rather than the JPEG that it actually is.|||Your function has to return the image as byte array (i.e. byte[]). In addition, the image type has to be set to "Database", otherwise the Value property is not interpreted as the actual image data.
--Robert
|||Awesome, it worked. When I changed my Source property to Database, I also took out my conversion statements so that it would return just an image file. Once I put the conversion-to-byte-array logic back in, it worked.Thank ye very much for your help.
No comments:
Post a Comment