You receive a "System.OutOfMemoryException" error message when you try to use the Bitmap.FromFile method in the .NET Framework 1.0 (810109)
The information in this article applies to:
- Microsoft .NET Framework 1.0
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
SYMPTOMSWhen you try to load an image by using the Bitmap.FromFile method in the Microsoft .NET Framework 1.0, you receive the
following error message: An unhandle exception of type
'System.OutOfMemoryException' occurred in
system.drawing.dll CAUSEThis problem may occur when you use the Bitmap.FromFile method and one of the following conditions is true:
- The image file is corrupted.
- The image file is incomplete.
Note You may experience this problem if your application is trying to
use the Bitmap.FromFile method on a file stream that is not finished writing to
a file. - The image file does not have a valid image format or GDI+ does not support the pixel format of the file.
- The program does not have permissions to access the image
file.
- The BackgroundImage propery is set directly from the Bitmap.FromFile method.
WORKAROUNDTo work around this problem, use the following guidelines
when you load images by using the Bitmap.FromFile method:
Note When you try to load an image from a file, you can catch the
exception and then report the error. For example, the following Microsoft Visual Basic
.NET code tries to load an image from a file: Try
PictureBox1.Image = Bitmap.From("c:\Badimage.gif")
Catch ex As Exception
MessageBox.Show("Error loading file","Error")
End Try
STATUS This
behavior is by design.
Modification Type: | Major | Last Reviewed: | 1/7/2005 |
---|
Keywords: | kbGDIPlus kbtshoot kbprb KB810109 kbAudDeveloper |
---|
|