Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get resource file values in Visual Basic?

I'm new to Visual Basic, and I'm having issues accessing the resource file for my project.

Dim rm As Resources.ResourceManager = New Resources.ResourceManager("MyProjectName.My.Resources.Resources", [Assembly].GetExecutingAssembly())
Dim myValue = rm.GetString(lookUpKey) 'boom Object reference not set to an instance of an object.

I think the issue is with the string "MyProjectName.My.Resources.Resources".

Would I be better off moving the strings into their own resource file?

like image 225
Biff MaGriff Avatar asked Apr 12 '11 17:04

Biff MaGriff


People also ask

How do I access resources in VB net?

You can access resources added through the Project Designer by using My. Resources. resourceName. You can also add or remove resource files by selecting your project in Solution Explorer and clicking Add New Item or Add Existing Item from the Project menu.

How do I access resource files in Visual Studio?

Open your project in Visual Studio and navigate to Solution Explorer. Expand the Resource Files folder, then: To open in the text editor, double-click the . manifest file.

How can I see the code of a RESX file?

Navigate to resources from File Structure Open a . resx file in the XML (Text) editor. Press Ctrl+Alt+F or choose ReSharper | Windows | File Structure from the main menu . Alternatively, you can press Ctrl+Shift+A , start typing the command name in the popup, and then choose it there.


3 Answers

I thought it was something similar to:

my.Resource.whateverhere

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

like image 134
Freesnöw Avatar answered Sep 20 '22 15:09

Freesnöw


Try

 Global.<MyNamespace>.My.Resources.<ResourceStringName>

to access Resource Strings

like image 20
Makah Avatar answered Sep 20 '22 15:09

Makah


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

or

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

like image 29
manji Avatar answered Sep 19 '22 15:09

manji