How do I load a resource from within my app

I am currently using the folowing syntax to load an Image ,
    upimage.FromFile("C:\Report.bmp")
If a add Report.bmp to my application ,how do I reference or load this Image  from within my app?
Cheers
visualbasicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ptakjaCommented:
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].GetExecutingAssembly.GetName.Name
DIm bmp as New Bitmap = [Assembly].GetExecutingAssembly.GetManifestResourceStream(AssyName & ".Report.bmp")

upimage.Image = bmp

The syntax for the filename in the GetManifestResourceStream method is <assemblyName>.File.extension

Jeff
0
visualbasicAuthor Commented:
this sugestion does not seem to work ,problem is with
DIm bmp as New Bitmap = [Assembly].GetExecutingAssembly.GetManifestResourceStream(AssyName & ".Report.bmp")

do you have any other sugestions

cheers
0
ptakjaCommented:
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.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

ptakjaCommented:
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].GetExecutingAssembly.GetName.Name
DIm bmp as New Bitmap = [Assembly].GetExecutingAssembly.GetManifestResourceStream(AssyName & ".Report.bmp")

upimage.Image = bmp

The syntax for the filename in the GetManifestResourceStream method is <assemblyName>.File.extension

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].GetExecutingAssembly.GetManifestResourceStream(AssyName & ".Report.bmp"))
 
 Sorry about that! :-|
0
ptakjaCommented:
Aghhh. this is how my day is going!

Dim bmp as New Bitmap([Assembly].GetExecutingAssembly.GetManifestResourceStream(AssyName & ".Report.bmp"))


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
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
0
visualbasicAuthor Commented:
thanks a million ptakja  ,that worked a treat!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.