title: Parameter is not valid. Stack Trace at System.Drawing.Bitmap..ctor(Stream stream)
body: <p>For some cases only i'm getting this error. "Parameter is not valid Stack Trace   at System.Drawing.Bitmap..ctor(Stream stream)" i am little confused how it is working for some records why not for other. Anyone please guide me to find my mistake will be very helpful..,</p>
  
  <p>Following are my codes.,</p>
  
  <pre><code>private void RefreshImage()
      {
          if (this.dsPatPhoto.dmDoc.Count &lt;= 0) return;
  
          byte[] patImage = null;
          byte[] driverLicImage = null;
  
          foreach (CmData.WrCmDoc.DsCmDoc.dmDocRow row in this.dsPatPhoto.dmDoc)
          {
              if (!row.IsIDDocTypeNull() &amp;&amp;
                  row.IDDocType == (short)AppCommonCfg.DocType.PatientDriverLicense)
              {
                  if (!row.IsDocImageNull())
                      driverLicImage = row.DocImage;
              }
              else
              {
                  if (!row.IsDocImageNull())
                      patImage = row.DocImage;
              }
          }
  
          System.IO.MemoryStream stream;
          if (patImage != null &amp;&amp; patImage.Length &gt; 0)
          {
              stream = new System.IO.MemoryStream(patImage, true);
              this.ucPictureEditPic.Clear();
              this.ucPictureEditPic.Image = new System.Drawing.Bitmap(stream);
          }
  
          if (driverLicImage != null &amp;&amp; driverLicImage.Length &gt; 0)
          {
              stream = new System.IO.MemoryStream(driverLicImage, true);
              this.ucPictureEditDL.Clear();
              this.ucPictureEditDL.Image = new System.Drawing.Bitmap(stream); //Error occurs here.
          }
  
      }
  </code></pre>