[ACCEPTED]-How do I get resource file values in Visual Basic?-embedded-resource

Accepted answer
Score: 10

I thought it was something similar to:


Is 2 that not the kind of resources you are looking 1 for?

Score: 4



to access Resource Strings


Score: 1

Refer to the MSDN article Retrieving Resources with the ResourceManager Class for naming convetions:

Dim myManager As New _
   System.Resources.ResourceManager("ResourceNamespace.myResources", _


Score: 1

Try ResourceManager("MyProjectName.Resources", ...), otherwise if it's the application 5 resources you can simply use My.Resources.HD (see here:My.Resources Object)


Open 4 Reflector, load your assembly there, go to resources, a 3 list of resources appears, search for the 2 one containg 'HD', copy the name (it's like 1 MyProjectName.Resources.resources), remove the last .resources and try with that.

Score: 1

If you load an external .resx file and want 14 it to show up under intellisense My.Resources 13 then you need to do 2 things.

First the file 12 should be in the root of your project. Simply 11 right click the project and do "Add Existing 10 Item", and give it your .resx file. You 9 should notice that there is no chevron to 8 expand the resx file like your built-in 7 resource file.

The last step is to highlight 6 your resx file and go to the properties 5 window. Under Custom Tool put "ResXFileCodeGenerator" and 4 under the Custom Tool NameSpace put "My.Resources". You 3 should now be able to programmatically access 2 this resource under My.Resources.[name of 1 the resx file].resource_item.

Score: 0

I was unable to access the resource file 9 until I moved the .resx file into its own 8 project and referenced that project from 7 my main one. I also had to create a dummy 6 class in that project so that it would compile 5 into a DLL file.

The code for accessing the 4 resource file is actually located in the 3 generated Resource.resx.vb file.

I was able 2 to access the resource file using the following 1 code.

'Name of Class Library where I moved the resx file
Dim classLibraryName As String = "ResourceProj"
'Name of Resource File without the .resx suffix
Dim resourceFileName As String = "Mappings"
'Finding the assembly of the resx file, ResourceProjClass is a dummy class I created so that the dll would build.
Dim myAssembly As Assembly = GetType(ResourceProj.ResourceProjClass).Assembly

Dim rm As Resources.ResourceManager = Nothing
rm = New Resources.ResourceManager(classLibraryName & "." & resourceFileName, GetType(myAssembly)
Return rm.GetString(lookUpKey)
Score: 0


Dim loginMessage As String = Global.Resources.NameOfYourResxFile.NameOFVariable


More Related questions