This is a migrated thread and some comments may be shown as answers.

xml string to byte[]

1 Answer 91 Views
BinaryImage
This is a migrated thread and some comments may be shown as answers.
Marco Teodoro
Top achievements
Rank 1
Marco Teodoro asked on 02 Sep 2010, 03:02 PM
hello.

this is my scenario.

i have a web service that brings some products, each product have a name, price, description and image in blob format.

so i'm getting this blob as string and i'm making Convert.FromBase64String(base64String) that return a byte[].

so far so goo, i think!

so, next i fill the property DataValue whit the byte array.

this binaryimage is inside one template of datalist.

but then when i'm trying to render the page e receive a error page with this exception:


Parameter is not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Parameter is not valid.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[ArgumentException: Parameter is not valid.]
   System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) +1144615
   System.Drawing.Image.FromStream(Stream stream) +8
   Telerik.Web.UI.ImageFilterHelper.CreateImgFromBytes(Byte[] image) +99

[ArgumentException: The provided binary data may not be valid image or may contains unknown header]
   Telerik.Web.UI.ImageFilterHelper.CreateImgFromBytes(Byte[] image) +173
   Telerik.Web.UI.RadBinaryImage.AutoAdjustImageElementSize(Byte[] dataValue) +50
   Telerik.Web.UI.RadBinaryImage.ProcessImageData() +191
   Telerik.Web.UI.RadBinaryImage.OnPreRender(EventArgs e) +41
   System.Web.UI.Control.PreRenderRecursiveInternal() +103
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496


Hope someone can help. 


best regards

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 07 Sep 2010, 08:42 AM
Hello Marco,

Verify that all the data records from the XML data contain valid image data. In other words, the byte[] that you get from an XML substring should be a valid image. Otherwise, you should not pass it to RadBinaryImage. If the problem persists, send us some sample XML data we can use to test your scenario locally.

Regards,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
BinaryImage
Asked by
Marco Teodoro
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or