0

I am facing and strange exception behavior, I have album of items, once I double clicked one of them a bigger form opens and shows the album picture in 650*650 , Before I call the ShowDialog for this since I exporting an image of size 650*650 from the a map

The issues when I am trying loading into picture box the image it throws me invalid parameter exception I tried to check and the image exporting to the right path and to the right folder the image size is less then 1MB

When I try to surround it with try catch block, In the catch block the loading image works with no exception I have no idea what's causing this expectation and surly this not the way I want to solve things, because I don't understand why the exception is happing and why in the catch block it works

Here the code but it's pretty simple

try
{
    pbImage.Paint += new PaintEventHandler(pbImage_Paint);
    ButtonZoomToRes.Click += new EventHandler(ButtonZoomToOriginalRes_Click);
    this.MouseWheel += new MouseEventHandler(DetectionContextViewForm_MouseWheel);
    pbImage.Image = new Bitmap(FilePath);
    pbImage.SetToOriginalZoom = true;
    pbImage.Show();
}
//if the excpetion occurs in the catch block it sucssed to load the image , have no idea why
catch (Exception ex)
{
    MessageBox.Show("Image faild to load, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    pbImage.Image = new Bitmap(FilePath);
    pbImage.SetToOriginalZoom = true;
    pbImage.Show();
}
pah
  • 4,700
  • 6
  • 28
  • 37
Zlex
  • 147
  • 2
  • 11
  • Maybe this post will help you: http://stackoverflow.com/questions/6333681/c-sharp-parameter-is-not-valid-creating-new-bitmap – Prisoner Jul 02 '14 at 09:49
  • Yeah, It Didn't help, My image size is small, 650*650 ,it shouldn't happend – Zlex Jul 02 '14 at 09:52

0 Answers0