Question

Locked

Refer to a Visual Studio Resource By Name?

By dogknees ·
How do I access a resource in my code by name?

I can do this:
strTemp = MyApp.My.Resources.FileServerName

I want to do something like this:
strTemp = MyApp.My.Resources("FileServerName")
or
strResourceName = "FileServerName"
strTemp = MyApp.My.Resources(strResourceName)

I'm working in Visual Basic and want to use the code in a class member function.

Can anyone assist please?

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Aye ResourceManager class

by Tony Hopkinson In reply to Refer to a Visual Studio ...

Here you go

http://msdn.microsoft.com/en-us/library/aa984408(v=vs.71).aspx

Collapse -

Not Working

by dogknees In reply to Refer to a Visual Studio ...

Thanks Tony, I tracked that down after posting.

I must be missing something obvious, but it just isn't working. Would the problem be that my resources are in the default resources.resx file? In the Solution Explorer, it appears under "Staff Manager\My Project\Resources.resx". (Application is called Staff Manager)

My code is as follows.

Dim rm As New System.Resources.ResourceManager("Staff Manager.My.Resources", [Assembly].GetExecutingAssembly)
ACL = rm.GetString("PasswordACL")

The error I get says, amongst other things, "Make sure "Staff Manager.My.Resources.resources" was correctly embedded or linked into the assembly "Staff Manager" at compile time, ..."

Any ideas or hints?
Thanks

Collapse -

Reponse To Answer

by Tony Hopkinson In reply to Not Working

Um nevere tried this myself and I'm a C# guy, but I did see this
http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager.aspx
Which seems to be as you suspect only works with a resources dll...
Ony other thing I can thik of trying, is going int debug and using the the ResourceSet Class to zip through what is in there and see if you can "see where you are sort of thing".
I'll have a we look when I get a minute myself, I like advance notice of gotchas, before they become gotchmes...

Back to Software Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums