title: A generic error occurred in GDI+ in C# (license plate reader)
body: <p>I am creating a LPR (License Plate Reader) in C#.</p>
  
  <p>My code is based on getting an image from camera and saving it in a location, then the LPR process the image to plain text .</p>
  
  <p>So every time the image taken by the cam should be replaced by new one.</p>
  
  <p>But when I try to save the image for the second time, I get this error.</p>
  
  <p>Here is where the problem starts.</p>
  
  <pre><code>if (pictureBox3.Image != null)
  {
              Bitmap varBmp = new Bitmap(pictureBox3.Image);
              Bitmap newBitmap = new Bitmap(varBmp);
              //Save First 
              varBmp.Save(Application.StartupPath + "\\ImageTest\\1.bmp", ImageFormat.Bmp);
              //Now Dispose to free the memory
              varBmp.Dispose();
              varBmp = null;                
  }
  else
  {
       MessageBox.Show("null exception"); 
  }
  </code></pre>
  
  <p>I dispose the image after saving it, still instead of replacing i get this why?</p>
  
  <p>I am adding more details, every time when the image is created it is processed all over by different function and events. I think those things might be holding that particular image...</p>
  
  <p>Snap click <a href="http://pastebin.com/QHXkqATb" rel="nofollow">http://pastebin.com/QHXkqATb</a></p>
  
  <p>Process image <a href="http://pastebin.com/MpAVacDr" rel="nofollow">http://pastebin.com/MpAVacDr</a></p>
  
  <p>OCR (optical character Recognizer) <a href="http://pastebin.com/sXPxzQ39" rel="nofollow">http://pastebin.com/sXPxzQ39</a></p>
  
  <p>Find License Plate <a href="http://pastebin.com/DH1SdebL" rel="nofollow">http://pastebin.com/DH1SdebL</a></p>
  
  <blockquote>
    <p>I have an imagebox and picture box1 which is holding these images for processing, therfore if you focus on that area you can find the  error.</p>
  </blockquote>
  
  <p>Any help is appreciated.</p>