visualbasic
asked on
How do I load a resource from within my app
I am currently using the folowing syntax to load an Image ,
upimage.FromFile("C:\Repor t.bmp")
If a add Report.bmp to my application ,how do I reference or load this Image from within my app?
Cheers
upimage.FromFile("C:\Repor
If a add Report.bmp to my application ,how do I reference or load this Image from within my app?
Cheers
ASKER
this sugestion does not seem to work ,problem is with
DIm bmp as New Bitmap = [Assembly].GetExecutingAss embly.GetM anifestRes ourceStrea m(AssyName & ".Report.bmp")
do you have any other sugestions
cheers
DIm bmp as New Bitmap = [Assembly].GetExecutingAss
do you have any other sugestions
cheers
Do you have the line above it in your code? AND did you follow Step 1 in my original post? I have 2 applications with embedded image resources that work just fine using this exact code (except for the file name) on both the full .NET Framework as well as the Compact Framework.
Whoops...wrong syntax. Try this:
Comment from ptakja
Date: 11/12/2004 06:36AM EST
Your Comment
Here's what you have to do:
1) Make sure the property "Build Action" is set to "Embedded Resource" for your image file(s). You can see this property by selecting the file in VS and looking at the properties.
2) To load the file as a resource:
Dim AssyName As String = [Assembly].GetExecutingAss embly.GetN ame.Name
DIm bmp as New Bitmap = [Assembly].GetExecutingAss embly.GetM anifestRes ourceStrea m(AssyName & ".Report.bmp")
upimage.Image = bmp
The syntax for the filename in the GetManifestResourceStream method is <assemblyName>.File.extens ion
Jeff
Comment from visualbasic
Date: 11/12/2004 12:46PM EST
Author Comment
this sugestion does not seem to work ,problem is with
DIm bmp as New Bitmap([Assembly].GetExecu tingAssemb ly.GetMani festResour ceStream(A ssyName & ".Report.bmp"))
Sorry about that! :-|
Comment from ptakja
Date: 11/12/2004 06:36AM EST
Your Comment
Here's what you have to do:
1) Make sure the property "Build Action" is set to "Embedded Resource" for your image file(s). You can see this property by selecting the file in VS and looking at the properties.
2) To load the file as a resource:
Dim AssyName As String = [Assembly].GetExecutingAss
DIm bmp as New Bitmap = [Assembly].GetExecutingAss
upimage.Image = bmp
The syntax for the filename in the GetManifestResourceStream method is <assemblyName>.File.extens
Jeff
Comment from visualbasic
Date: 11/12/2004 12:46PM EST
Author Comment
this sugestion does not seem to work ,problem is with
DIm bmp as New Bitmap([Assembly].GetExecu
Sorry about that! :-|
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is the Build Action property set to for the embedded file in the assembly? Is it Compile, Content, or Embedded Resource? Are you getting any errors?
Bob
Bob
ASKER
thanks a million ptakja ,that worked a treat!
1) Make sure the property "Build Action" is set to "Embedded Resource" for your image file(s). You can see this property by selecting the file in VS and looking at the properties.
2) To load the file as a resource:
Dim AssyName As String = [Assembly].GetExecutingAss
DIm bmp as New Bitmap = [Assembly].GetExecutingAss
upimage.Image = bmp
The syntax for the filename in the GetManifestResourceStream method is <assemblyName>.File.extens
Jeff