G
Guest
I have an application that I have used for years on 32-bit XP. It also
appears to run properly on 32-bit Vista - at least I haven't had any users
complain.
When I try to run the app on Vista X64, I get errors randomly in
System.Drawing and GDI+ when I call Image.FromStream(Stream).
If the System.Drawing exception occurs, it is an ArgumentException and the
message is "Parameter is not valid." The stack trace provides this
information:
at System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement, Boolean validateImageData)\r\n at
System.Drawing.Image.FromStream(Stream stream)
It appears to be an internal error in System.Drawing - or GDI+ that
System.Drawing is not passing on unchanged so I can't tell.
If the GDI+ error occurs, the exception is of type
System.Runtime.InteropServices.ExternalException. The error message says "A
generic error occurred in GDI+." The stack trace shows the same message as
above for the System.Drawing exception.
I get either one or the other, I don't get both in the same instance.
I create a MemoryStream in a BackgroundWorker thread with this code:
MemoryStream imageStream = null;
if (files.Length > 0 && File.Exists(picturePath))
{
imageStream = GetImageStream(picturePath);
}
That stream is passed to the BackgroundWorker's ProgressChanged event as a
property of a custom class passed in the UserState object of the
ProgressChangedEventArgs and converted to an image with:
Image mg = null;
try
{
mg = Image.FromStream(p.PictureData);
}
catch(Exception ex)
{
MessageBox.Show("Cannot create image for " +
p.Mp3FileName + "\r\n" + "Exception: " + ex.Message);
}
where p is the object instance that I passed in UserData.
A strange thing is that if I set a break point on the catch block and when
the break occurs I run:
mg = Image.FromStream(p.PictureData);
from the Immediate Window, the call is successful and mg will hold the
expected image. That tells me that the problem is not in the image data
itself.
Please keep in mind that this does only happen in Vista X64, not in Vista X86.
Thanks in advance for any help with this.
Dale
appears to run properly on 32-bit Vista - at least I haven't had any users
complain.
When I try to run the app on Vista X64, I get errors randomly in
System.Drawing and GDI+ when I call Image.FromStream(Stream).
If the System.Drawing exception occurs, it is an ArgumentException and the
message is "Parameter is not valid." The stack trace provides this
information:
at System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement, Boolean validateImageData)\r\n at
System.Drawing.Image.FromStream(Stream stream)
It appears to be an internal error in System.Drawing - or GDI+ that
System.Drawing is not passing on unchanged so I can't tell.
If the GDI+ error occurs, the exception is of type
System.Runtime.InteropServices.ExternalException. The error message says "A
generic error occurred in GDI+." The stack trace shows the same message as
above for the System.Drawing exception.
I get either one or the other, I don't get both in the same instance.
I create a MemoryStream in a BackgroundWorker thread with this code:
MemoryStream imageStream = null;
if (files.Length > 0 && File.Exists(picturePath))
{
imageStream = GetImageStream(picturePath);
}
That stream is passed to the BackgroundWorker's ProgressChanged event as a
property of a custom class passed in the UserState object of the
ProgressChangedEventArgs and converted to an image with:
Image mg = null;
try
{
mg = Image.FromStream(p.PictureData);
}
catch(Exception ex)
{
MessageBox.Show("Cannot create image for " +
p.Mp3FileName + "\r\n" + "Exception: " + ex.Message);
}
where p is the object instance that I passed in UserData.
A strange thing is that if I set a break point on the catch block and when
the break occurs I run:
mg = Image.FromStream(p.PictureData);
from the Immediate Window, the call is successful and mg will hold the
expected image. That tells me that the problem is not in the image data
itself.
Please keep in mind that this does only happen in Vista X64, not in Vista X86.
Thanks in advance for any help with this.
Dale