xml string to byte[]

2 posts, 0 answers
  1. Marco Teodoro
    Marco Teodoro avatar
    53 posts
    Member since:
    Apr 2010

    Posted 02 Sep 2010 Link to this post

    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
  2. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 07 Sep 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top