
How to access embedded resources?
There are two gotchas when retrieving a resource. The first is that even
though VB is not case sensitive, the frameworks function
GetManifestResourceStream() is, so you need to make sure the string case
matches the name in your project. The other gotcha is that the name must be
fully qualified, e.g. "ProjectName.Test.gif"
Tyler
Vb.Net Development
This posting is provided "AS IS" with no warranties, and confers no rights.
Quote:
> I want to access an image in my WinForm UserControl project which I have
> already added to the project and set it to "Embedded Resource".
> Now tried to access this image with:
> Private imgTest As Image = Bitmap.FromStream( _
> Me.GetType().Assembly.GetManifestResourceStream("Test.gif"))
> This gives no errors when writing it (no squiggly underlining), and it
> compiles without any errors as well.
> However, if I add it to the Toolbox (which also works without problems)
and
> then try to create an instance of it on a form, I only get the following
> error message:
> "An error has occurred trying to create an instance of blabla. The error
> is: 'null' is not a valid value for 'stream'".
> Looks like my declaration is wrong... so, how should the declaration look
> like?
> --
> Tenchi (remove 'spam.be.gone' for emails)
> My VB.net Download Manager (Version 1.21.1400.0)
> Homepage: http://mitglied.lycos.de/downloadwunder/
> Mailing list: http://de.groups.yahoo.com/group/dw-net/