L
Len Weaver
Hello all,
I have some fairly simple code that keeps throwing an exception.
The exception message is "A generic error occurred in GDI+.". Okay, I
know what you're thinking. You're thinking: "But Len, that error
message is soooo descriptive how could you possibly not know what the
problem is?".
There are many examples of this problem listed on Google groups, but
they either involve ASP.Net applications, or saving an image to disk.
None of the solutions listed seem to apply to my situation. Here is
some sample code that replicates my problem:
public Bitmap MenuImage {
get {
Bitmap result = null;
Stream s = null;
try {
s = this.GetType().Assembly.GetManifestResourceStream
("MyNamespace.Graphics.SECUR07.ICO");
result = (Bitmap)Image.FromStream( s );
}
catch( Exception Ex ) {
throw new ApplicationException( "Unable to retrieve Add-In "
+
"menu bitmap.", Ex );
}
finally {
if( s != null ) s.Close();
}
return result;
}
}
private void pictureBox1_Click(object sender, System.EventArgs e) {
pictureBox1.Image = ((IMenuImage)this).MenuImage; //Exception
thrown here
}
The 'Build Action' for "SECUR07.ICO" is set to 'Embedded Resource'.
Any assistance would be appreciated.
Thanks,
Len
I have some fairly simple code that keeps throwing an exception.
The exception message is "A generic error occurred in GDI+.". Okay, I
know what you're thinking. You're thinking: "But Len, that error
message is soooo descriptive how could you possibly not know what the
problem is?".
There are many examples of this problem listed on Google groups, but
they either involve ASP.Net applications, or saving an image to disk.
None of the solutions listed seem to apply to my situation. Here is
some sample code that replicates my problem:
public Bitmap MenuImage {
get {
Bitmap result = null;
Stream s = null;
try {
s = this.GetType().Assembly.GetManifestResourceStream
("MyNamespace.Graphics.SECUR07.ICO");
result = (Bitmap)Image.FromStream( s );
}
catch( Exception Ex ) {
throw new ApplicationException( "Unable to retrieve Add-In "
+
"menu bitmap.", Ex );
}
finally {
if( s != null ) s.Close();
}
return result;
}
}
private void pictureBox1_Click(object sender, System.EventArgs e) {
pictureBox1.Image = ((IMenuImage)this).MenuImage; //Exception
thrown here
}
The 'Build Action' for "SECUR07.ICO" is set to 'Embedded Resource'.
Any assistance would be appreciated.
Thanks,
Len