VS2005 C# and Resources

B

bob

Hi,
I am having trouble with Resources of a windows app.
If I understand correctly.
1) New C# Windows app. Namespace 'TestResources'
2) Edit default Resources file, set String1 value to say "MyApp"
3) Put the following code in ctor after InitializeComponent
ResourceManager rm = new ResourceManager("Resources",
Assembly.GetExecutingAssembly());

String s = rm.GetString("String1");///BREAKS HERE///

MessageBox.Show(s);

It breaks with a MissingManifestResourceException

Am I missing a setting ?

Thanks

Bob
 
?

=?iso-8859-1?Q?Lasse=20V=e5gs=e6ther=20Karlsen?=

Hi,
I am having trouble with Resources of a windows app.
If I understand correctly.
1) New C# Windows app. Namespace 'TestResources'
2) Edit default Resources file, set String1 value to say "MyApp"
3) Put the following code in ctor after InitializeComponent
ResourceManager rm = new ResourceManager("Resources",
Assembly.GetExecutingAssembly());
String s = rm.GetString("String1");///BREAKS HERE///

MessageBox.Show(s);

It breaks with a MissingManifestResourceException

Am I missing a setting ?

Thanks

Bob

VS2005 produces typesafe access to your resources, at least if you use the
default editors. Try Resources.String1.
 
B

Bob

Hi,
Thanks ,
You put me on the right track.
Intellisense access to the default Resources is a fully formed name starting
at project Level.
(Project TestResources)
String s =TestResources.Properties.Resources.String1;
Is that little pearl of wisdom documented anywhere?
Are you told that you need "using TestResources.Properties" to make
reasonable use of the Resources object?
Nooo you are not.
Documentation in this area is inadequate in my opinion.

Thanks again for your help.
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top