try { System.Windows.Forms.PictureBox picturebox = new System.Windows.Forms.PictureBox(); // this line causes the InvalidCastExeption // the Bitmap is available and shown proper in the Picturebox. // the Debugger stop only in this line if i activate // Debugging->Common Language Runtime-> System -> System.InvalidCastException // but it jumps over the two catch blocks picturebox.Image = new System.Drawing.Bitmap("Bitmap.bmp"); this.Form1.Controls.Add(picturebox); } catch (System.InvalidCastException ice) { System.Console.WriteLine(ice.Message); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); }
new
picturebox.Image = new System.Drawing.Bitmap("Bitmap.bmp");
System.Drawing
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)