Catch to avoid System.AccessViolationException

Viewed 33

When I size up a pictureBox to be really big, I get a "System.AccessViolationException" exception. But I can't seem to avoid it with a try / catch... How can I get this to not throw an exception?

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            pic.Image = Image.FromFile(@"D:\barren.jpg");
            pic.SizeMode = PictureBoxSizeMode.StretchImage;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                pic.Width = 30000;
                pic.Height = 35000;
            }
            catch { MessageBox.Show("catch"); }
        }
0 Answers
Related