473,770 Members | 4,553 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 1858
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
3760
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
2294
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
2292
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
5430
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
1953
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
1603
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
1384
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
1233
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
4466
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
9439
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,...
0
10237
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9882
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...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3987
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
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
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.