Results 1 to 2 of 2

Thread: random errors with picturebox. please help!

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    1

    random errors with picturebox. please help!

    hi there,



    i am creating a basic accounts program using text files on a pda.



    i have almost finished but i keep getting the same error randomly when u run the program.



    on each form of the smart device application i have a picturebox for the background image. i am using jpegs for these images.



    some times the program runs fine but other times i get error to do with the pcitureboxes. the errors vs.net gives me is;



    An unhandled exception of type 'System.Exception' occurred in System.Drawing.dll

    Additional information: Exception



    and it highlights the code;



    Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)



    I do not understand why it works sometimes and not others. it has the same errors on different forms of the program, not only one.



    Any help would be fantastic, as i am pulling my hair out now!



    thanks in advance

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: random errors with picturebox. please help!

    Wrap that line in a Try....Catch block as a first step. For one thing, you will get better information on the exception, for another thing, this is EXACTLY the situation where exception handling is needed. Whenever you read from a file, you should do so in a Try block, because there is always a chance, however remote, that something will go wrong for reasons beyond your control. Now, in this case, your exception message looks like it gives little info, and you might find that when you look at the exception message in the handler (the first thing to try in the handler is just to catch the exception, and show a messagebox with exception.Message), that there really isn't much useful information there. However, this will be the start, and the message might make the problem entirely obvious.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width