title: "Parameter is not valid" when Converting byte to image in asp.net
body: <p>I got one error "Parameter is not valid" when i converting database byte array to image from this code.</p>
  
  <pre><code>try
  {
      DataTable dt = dbo.GetRecordsWithQuery("select * from Users where UserID='" +Session["userid"].ToString()+ "'");
      byte[] image_user = (byte[])dt.Rows[0]["Image"]; // from this i got the error. Also the image_user dimension is 13
      System.Drawing.Image myimage = BinaryToImage(image_user);
      myimage.Save(Server.MapPath("~/User/images/profileImg/img1.jpg"));
      img1.ImageUrl = "~/User/images/profileImg/img1.jpg";
      url = img1.ImageUrl;
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>public static System.Drawing.Image BinaryToImage(byte[] binaryData)
  {
      MemoryStream ms = new MemoryStream(binaryData);
      System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
      return returnImage;
  }
  </code></pre>