472,794 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Problem Adding and Using Resource Files

Hey All,

I am building a solution which will have many strings that will need to be
localized (i.e. strings for toolbars, strings for different WinForms,
strings for messages and error messages, etc.).

I am having trouble accessing string file resources.

What I want to do is to break out strings into separate files so that they
are easier to manage and such that I don't have to look through hundreds to
find, edit or delete something.

How can I use code similar to that below:

Dim rm As ResourceManager
Dim Message as StringBuilder

rm = New ResourceManager("StringTable", Me.GetType().Assembly)

Message = New StringBuilder()
Message.Append(rm.GetString("String1"))
Message.Append(rm.GetString("String2"))
MessageBox.Show(Message.ToString())

Right now, when I try the above I get an error claiming that such resources
cannot be found. The text file is listed under the resources. What's
wrong?

Am I missing something in regards to the structure of the text file or
perhaps how it is added?

Please advise.

Thanks,

TC
Nov 8 '06 #1
4 1806
Am I missing something in regards to the structure of the text file or
perhaps how it is added?
I assume you're using Visual Studio (?). If so then are you aware that it
already has a built-in mechanism to handle strings for you (with relatively
little work on your part)?
Nov 8 '06 #2
Hey Larry,

As I mentioned in the original post, I am using the stings available under
"Resources".

What I am asking for is a way to segregate these strings into intelligent
collections probably via separate files.

That said, how can I load and use separate resource files into the list of
resources?

How can I use code similar to that below:

Dim rm As ResourceManager
Dim Message as StringBuilder

rm = New ResourceManager("StringTable", Me.GetType().Assembly)

Message = New StringBuilder()
Message.Append(rm.GetString("String1"))
Message.Append(rm.GetString("String2"))
MessageBox.Show(Message.ToString())

Regards,

TC
"Larry Smith" <no_spam@_nospam.comwrote in message
news:ul**************@TK2MSFTNGP02.phx.gbl...
>Am I missing something in regards to the structure of the text file or
perhaps how it is added?

I assume you're using Visual Studio (?). If so then are you aware that it
already has a built-in mechanism to handle strings for you (with
relatively little work on your part)?

Nov 8 '06 #3
Hey Larry,
>
As I mentioned in the original post, I am using the stings available under
"Resources".

What I am asking for is a way to segregate these strings into intelligent
collections probably via separate files.

That said, how can I load and use separate resource files into the list of
resources?

How can I use code similar to that below:

Dim rm As ResourceManager
Dim Message as StringBuilder

rm = New ResourceManager("StringTable", Me.GetType().Assembly)

Message = New StringBuilder()
Message.Append(rm.GetString("String1"))
Message.Append(rm.GetString("String2"))
MessageBox.Show(Message.ToString())
What I was alluding to is that you don't need to do this (or rather you're
probably making your life more difficult). First, ".resx" files for forms
are handled automatically by VS (referring to all strings that appear on
your forms for instance). If you're not aware of the details please let me
know (it seems that way). For other resources like error messages and so
forth, go to Solution Explorer and right-click your project's node. Select
"Properties" from the context menu and click "Resources" on the left-hand
side. A table now appears where you can enter all (non-form) resources which
are usually strings (you may have to click on the notice in the middle of
the window first if there is one - it will be present if it's the first time
doing this). VS then creates a wrapper class called "Resources" where you
can now access any single resource (string or whatever) via the
<YourProjectNamespace>.Properties.Resources.<Resou rceNamestatic property
(a "using <YourProjectNamespace>.Properties" statement is required in each
source file of course). For instance, if you add "MyString=Whatever" to the
table and your project's namespace is "YourProjectNamespace", you can do
this:

using YourProjectNamespace.Properties;
// ...
string MyString = Resources.MyString;

You can access all resources this way, not just strings.
Nov 9 '06 #4
Hey Larry,

Yes, I am already using the catch-all resources file and I'm also using the
resource files exposed to userforms.

My question is, if I want to, how can I break the strings in the catch-all
resource out into separate files?

Regards,

Todd

"Larry Smith" <no_spam@_nospam.comwrote in message
news:uw**************@TK2MSFTNGP04.phx.gbl...
>Hey Larry,

As I mentioned in the original post, I am using the stings available
under "Resources".

What I am asking for is a way to segregate these strings into intelligent
collections probably via separate files.

That said, how can I load and use separate resource files into the list
of resources?

How can I use code similar to that below:

Dim rm As ResourceManager
Dim Message as StringBuilder

rm = New ResourceManager("StringTable", Me.GetType().Assembly)

Message = New StringBuilder()
Message.Append(rm.GetString("String1"))
Message.Append(rm.GetString("String2"))
MessageBox.Show(Message.ToString())

What I was alluding to is that you don't need to do this (or rather you're
probably making your life more difficult). First, ".resx" files for forms
are handled automatically by VS (referring to all strings that appear on
your forms for instance). If you're not aware of the details please let me
know (it seems that way). For other resources like error messages and so
forth, go to Solution Explorer and right-click your project's node. Select
"Properties" from the context menu and click "Resources" on the left-hand
side. A table now appears where you can enter all (non-form) resources
which are usually strings (you may have to click on the notice in the
middle of the window first if there is one - it will be present if it's
the first time doing this). VS then creates a wrapper class called
"Resources" where you can now access any single resource (string or
whatever) via the
<YourProjectNamespace>.Properties.Resources.<Resou rceNamestatic property
(a "using <YourProjectNamespace>.Properties" statement is required in each
source file of course). For instance, if you add "MyString=Whatever" to
the table and your project's namespace is "YourProjectNamespace", you can
do this:

using YourProjectNamespace.Properties;
// ...
string MyString = Resources.MyString;

You can access all resources this way, not just strings.

Nov 9 '06 #5

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

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
1
by: Stefan Turalski \(stic\) | last post by:
Hi, What I need to do is adding some support for resources files to my application. What I did is: MyAppMain <- startup project MyAppHelper <- project which has MyAppResourcesClass (al a...
0
by: Rob | last post by:
Hi Visual Studio.NET 2002 v7.0 Windows XP (all service packs up to date) Working on Clearcase MVFS mapped drive. When compiling my ATL control, I always have to hit Rebuild Solution. If I...
7
by: Wysiwyg | last post by:
Is there any way to add an embedded resource to a project without copying it to the project's directory? I have shared resources and don't want each project using the images, xml files, etc. to...
2
by: Rob Garfoot | last post by:
I'm hoping someone here can help with this one as I've been looking all around for a solution to this and I've yet to find one that is satisfactory. I'm trying to add support for different...
1
by: E. Tom Jorgenson | last post by:
I've run into a problem on a couple of projects that I think I've identified - but would like confirmation of what I think is going on. Also interested in any fast solutions to fix the user...
4
by: TCook | last post by:
Hey All, I am building a solution which will have many strings that will need to be localized (i.e. strings for toolbars, strings for different WinForms, strings for messages and error messages,...
0
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I have some web pages and user controls (ASCX), I switched my user control to Design View in my VS 2005 (SP1), I chose "Tools --Generate Local Resource" menu to create resource files. ...
5
by: DBC User | last post by:
I have a situation, where I need to add 4 or 5 data files (they change every time I build) in my project during build time and somehow I need a way to access these files during runtime. So I have...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.