G
Guest
Whenever I try to load a bitmap using the standard code:
Bitmap myBitmap = new Bitmap(this.GetType(), "bitmapResourceName")
I always end up with an error of the form "Resource "bitmapResourceName"
could not be found in class MyClass".
This seems to be something to do with having renamed either the namespace or
the class. Is this a known bug? The get-around seems to be to use the
following code:
string strNameSpace =
System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString();
System.IO.Stream stream
=System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(strNameSpace + "." + "bitmapResourceName");
Bitmap myBitmap = new Bitmap(stream);
but this seems awfully hamfisted compared to the more elegant original.
Bitmap myBitmap = new Bitmap(this.GetType(), "bitmapResourceName")
I always end up with an error of the form "Resource "bitmapResourceName"
could not be found in class MyClass".
This seems to be something to do with having renamed either the namespace or
the class. Is this a known bug? The get-around seems to be to use the
following code:
string strNameSpace =
System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString();
System.IO.Stream stream
=System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(strNameSpace + "." + "bitmapResourceName");
Bitmap myBitmap = new Bitmap(stream);
but this seems awfully hamfisted compared to the more elegant original.