473,383 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Use of resource images

Hi

I added a Resource file to my application then I added 2 images to this file

I made sure to set the set the Build Option of the images to 'Embedded
Resource'

But I still can't find them

I tried the following 2 methods

1. Dim rm As New Resources.ResourceManager("Images", _
System.Reflection.Assembly.GetExecutingAssembly())
Dim bmUK As Bitmap = CType(rm.GetObject("UKFlag.bmp"), Image)

The error I get is that the application can't find this image
The name of the Resource file is Images

Method 2
Dim bmAmazonUK As Bitmap = New Bitmap(
System.Reflection.Assembly.GetExecutingAssembly.Ge tManifestResourceStream("UKFlag.bmp"))
'

Any advice will be appreciated

Thank you,
Samuel

Jun 27 '08 #1
3 1968
The second method now works,

I qualify the name of the image with the namespace
"Samuel" <sa************@ntlworld.comwrote in message
news:uQ*************@TK2MSFTNGP04.phx.gbl...
Hi

I added a Resource file to my application then I added 2 images to this
file

I made sure to set the set the Build Option of the images to 'Embedded
Resource'

But I still can't find them

I tried the following 2 methods

1. Dim rm As New Resources.ResourceManager("Images", _
System.Reflection.Assembly.GetExecutingAssembly())
Dim bmUK As Bitmap = CType(rm.GetObject("UKFlag.bmp"), Image)

The error I get is that the application can't find this image
The name of the Resource file is Images

Method 2
Dim bmAmazonUK As Bitmap = New Bitmap(

System.Reflection.Assembly.GetExecutingAssembly.Ge tManifestResourceStream("UKFlag.bmp"))
'

Any advice will be appreciated

Thank you,
Samuel

Jun 27 '08 #2
"Samuel" <sa************@ntlworld.comschrieb:
I added a Resource file to my application then I added 2 images to this
file

I made sure to set the set the Build Option of the images to 'Embedded
Resource'

But I still can't find them
If you are using VB 2005/2008, you can access the resource via
'My.Resources.<resource name>'. The advantage of this method is that access
to resources is bound at compile time and thus type-checked.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jun 27 '08 #3
Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:eD**************@TK2MSFTNGP05.phx.gbl...
"Samuel" <sa************@ntlworld.comschrieb:
>I added a Resource file to my application then I added 2 images to this
file

I made sure to set the set the Build Option of the images to 'Embedded
Resource'

But I still can't find them

If you are using VB 2005/2008, you can access the resource via
'My.Resources.<resource name>'. The advantage of this method is that
access to resources is bound at compile time and thus type-checked.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Carl Scarlett | last post by:
When I display icons in controls from an imagelist, the icons are "corrupted" if they are added from a resource (or a file) but are fine if I add them using the designer at design time. I need to...
0
by: #Hai | last post by:
Hi, I have a picture box control in my form and I have 2 .GIF (animated GIF image). And I want to display those GIF image in my picture-box (at first, I want the control to show the first image...
4
by: Ed Sutton | last post by:
I have been searching for how to get an icon resource and load it into an ImageList. I added an *.ico file to my project and set the files "Build Action" to "Embedded Resource". Is there any easy...
1
by: Ed Sutton | last post by:
How can I load a resource from any namespace in my project? I have all my icons located under the following namespace: ..\resources\images\ For example, I can not figure out how to load them...
1
by: Roman Muntyanu | last post by:
Hi all, I created resource dll dynamicaly using this code AppDomain curDom = AppDomain.CurrentDomain; AssemblyName myAssemblyName = new AssemblyName(); imagesAssemblyName.Name = "Images";...
2
by: Don Tucker | last post by:
Hello, I have a Windows Application that needs to load multiple image files in response to users clicking buttons. Currently, I just have these images as .jpg files on disk, but I don't want to...
7
by: craig | last post by:
....quick question for anyone who might have some experience with .net resource files in VS 2003. I have an application that is not localized, but I would still like to be able to place all of...
1
by: Nickneem | last post by:
The following is driving me mad: VS2005 Compact framework, project upgraded from 2003. I get a cast exeception error trying to populate an imagelist (code is by design)...
2
by: =?Utf-8?B?R3JlZw==?= | last post by:
I've added some ICO Images to some buttons on my forms. I added them by selecting an Image via the "Select Resource" window. Anyway, all of my images are working just fine, I am getting a WARNING...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.