|
-
May 9th, 2002, 06:37 PM
#1
Thread Starter
Addicted Member
Using resources (resx) in VB.NET
Hi,
I've been trying to use resources in VB.NET for the past 4 hours without any luck...
I added a resource file to my project, called iConvert.resx, then I added a string to it:
name: test, value: eureka!, comment: (null), type: String, mimetype: (null)
Then, using this code:
VB Code:
Module MMain
Public gresMan As Resources.ResourceManager = New Resources.ResourceManager("iConvert", System.Reflection.Assembly.GetAssembly(GetType(MMain)))
Sub Main()
MessageBox.Show(gresMan.GetString("test"))
End Sub
End Module
I get an error telling me to make sure I linked/compiled iConvert.resources...
Help me please!
Live your own life, for you will die your own death.
-
May 9th, 2002, 07:57 PM
#2
Addicted Member
I know your pain. For me it took two days to get my resource to work.
Try using this line
Me.GetType.Assembly.GetExecutingAssembly()
instead of this line.
System.Reflection.Assembly.GetAssembly(GetType(MMain))
Hope it works for you.
That which does not kill us, only makes us stronger. 
-
May 13th, 2002, 11:41 AM
#3
Thread Starter
Addicted Member
thanks for replying, but unfortunately, the Me keyword is not valid inside modules 
any other ideas?
Live your own life, for you will die your own death.
-
May 13th, 2002, 12:03 PM
#4
Thread Starter
Addicted Member
I also tried:
gfrmConvert.GetType.Assembly.GetExecutingAssembly
with the same result...
gfrmConvert is an instance of the main form.
If I use this:
Resources.ResourceManager(GetType(FMain))
I get no error, but it does not retrieve the string when using GetString...
Live your own life, for you will die your own death.
-
May 13th, 2002, 05:29 PM
#5
Addicted Member
Hi,
I'm not positive that the line in question is your problem, but it was in my case.
How about this line?
System.Reflection.Assembly.GetExecutingAssembly
That which does not kill us, only makes us stronger. 
-
May 14th, 2002, 11:51 AM
#6
Thread Starter
Addicted Member
hey, could you give me an example of your working code? I can't make mine work
Live your own life, for you will die your own death.
-
May 14th, 2002, 10:41 PM
#7
Addicted Member
Dim RM As New ResourceManager("MyApp.MyResStrings", System.Reflection.Assembly.GetExecutingAssembly())
MsgBox(RM.GetString("MyString"))
Hope this helps.
That which does not kill us, only makes us stronger. 
-
May 15th, 2002, 11:44 AM
#8
Thread Starter
Addicted Member
well, it would be awesome if you could put all the code (the whole solution, zipped) related, because I don't think that the constructor is what is causing the problem... or if anyone can point me to a full example, I'll be very grateful 
thanks for your help so far!
Live your own life, for you will die your own death.
-
May 15th, 2002, 12:23 PM
#9
Thread Starter
Addicted Member
-
Jan 11th, 2005, 05:59 AM
#10
Frenzied Member
Re: Using resources (resx) in VB.NET
Right...i am absolutely confused by resource manager...
how do you create one ?
I need to put all my images into one .resx file...
how?????
grrr
-
Dec 11th, 2006, 05:36 PM
#11
Addicted Member
Re: Using resources (resx) in VB.NET
Wow, this is a very old thread, but perhaps this will help someone using VB.NET 2005.
Right-click 'Project Properties' in the Solution Explorer
Select ADD, then NEW ITEM
Select 'Resources File'
Choose 'Add Resources' and select the images you want to embed (Image1.jpg)
In your application, add a PictureBox (PictureBox1)
In your code, add the following in the proper context with what you are doing:
PictureBox1.Image = My.Resources.Images.Image1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|