473,695 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ("StringTabl e", Me.GetType().As sembly)

Message = New StringBuilder()
Message.Append( rm.GetString("S tring1"))
Message.Append( rm.GetString("S tring2"))
MessageBox.Show (Message.ToStri ng())

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 1854
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 ("StringTabl e", Me.GetType().As sembly)

Message = New StringBuilder()
Message.Append( rm.GetString("S tring1"))
Message.Append( rm.GetString("S tring2"))
MessageBox.Show (Message.ToStri ng())

Regards,

TC
"Larry Smith" <no_spam@_nospa m.comwrote in message
news:ul******** ******@TK2MSFTN GP02.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 ("StringTabl e", Me.GetType().As sembly)

Message = New StringBuilder()
Message.Append( rm.GetString("S tring1"))
Message.Append( rm.GetString("S tring2"))
MessageBox.Show (Message.ToStri ng())
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
<YourProjectNam espace>.Propert ies.Resources.< ResourceNamesta tic property
(a "using <YourProjectNam espace>.Propert ies" statement is required in each
source file of course). For instance, if you add "MyString=Whate ver" to the
table and your project's namespace is "YourProjectNam espace", you can do
this:

using YourProjectName space.Propertie s;
// ...
string MyString = Resources.MyStr ing;

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@_nospa m.comwrote in message
news:uw******** ******@TK2MSFTN GP04.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 ("StringTabl e", Me.GetType().As sembly)

Message = New StringBuilder()
Message.Append( rm.GetString("S tring1"))
Message.Append( rm.GetString("S tring2"))
MessageBox.Show (Message.ToStri ng())

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
<YourProjectNam espace>.Propert ies.Resources.< ResourceNamesta tic property
(a "using <YourProjectNam espace>.Propert ies" statement is required in each
source file of course). For instance, if you add "MyString=Whate ver" to
the table and your project's namespace is "YourProjectNam espace", you can
do this:

using YourProjectName space.Propertie s;
// ...
string MyString = Resources.MyStr ing;

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
3753
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 (ClassB* b; b->func(); ) the base-class function is called instead of the new function in the derived class. All other similar functions (virtual in the base class and overwritten in the the derived class) work fine, it's just this one function. ...
1
2291
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 library project) This class call methode : ResourceManager MyAppResourceManager = new ResourceManager("MyAppMain.Resources", Assembly.GetExecutingAssembly()); and I obtain error which tell that there is no propertly added
0
2289
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 just build, I get a "ExportText fatal error LNK1000: Internal error during ProcessResFiles" error. Setting verbose output on the linker gives the attached output. I have two resource files, One is project specfic and the
7
5421
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 need to be updated with the current copy before being built. I also don't want projects being built with the old copy. Thanks! Bill
2
1949
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 languages to my ASP.NET project. I have read the docs in MSDN and several sites and newsgrops but still can't get this working as advertized. I have created string resources in both a .txt and a .resx
1
1590
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 controls/pages that resulted from this. On these projects the page design was done with designers who used pure HTML with an HTML editing tool outside of Visual Studio. The developers then created the empty pages/user controls, copied the HTML code...
4
1380
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, 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
0
1229
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. After a while, my VS2005 reported "Start creating resource content and adding 'meta:' attributes to server controls and directives. Finished creating resource content and adding 'meta:' attributes."
5
4464
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 2 questions 1. Is it possible to identify all the files in the resource file during runtime by name of the file? 2. Is it possible to add files to a project at build time to make an exe with those files? Thanks.
0
8640
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8582
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8860
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7670
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4587
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3018
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1980
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.