How to release resouces used by a PictureBox and still use it

occr
occr used Ask the Experts™
on
I have a program that uses PictureBox control to display a tiff image. The only property/method i am using for this control is the Handle. I use routines from a proprietary DLL to manipulate the image, basically display and merge text into the tiff image.

The issue i am having is that after about two hundred images have been processed, the program crashes and displays the message, "Screen-compatible bitmap cannot be created. The screen bitmap format cannot be determined."

If I reduce the amount of text that i add to the tiff image by half then i can process almost twice as many (almost 350+) images. Also if i add and use a second PictureBox control and switch to it after processing about 175 images i can process twice as many images in one run.
I think that the resources being used by the PictureBox contol are not being released.

If i use the Dispose method to release resources, i can no longer use the PictureBox control. I get the message "Cannot access a disposed object".

How can i release resources used by the PictureBox control after processing each image and still use it?

Any help is greatly appreciated.  Thank you.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
Commented:
"The only property/method i am using for this control is the Handle. I use routines from a proprietary DLL to manipulate the image..."

Sounds to me like the problem is WITHIN the DLL!  If all you are doing is passing the Handle to the DLL then it is the DLL that is improperly allocating resources and not releasing them.  There isn't anything you could do directly with the PictureBox to fix this problem in the DLL....

What is the name of the DLL?

Author

Commented:
You were right i just had to dig into the DLL documentation to fix this issue. It's just that i had never used the PictureBox control before and wanted to be sure thatit's not the culprit. Thank you.
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
Glad the DLL was well documented!...  =)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial