Im only try to get a string...

  • Thread starter Thread starter Sam Martin
  • Start date Start date
S

Sam Martin

from a resource file.

Hi all,

Im having a bit of a moment.

I've got resource files in each of my assemblies, just named like
"Labels.resources" for example.

I've got a commond base method in one of my classes, that when given the
resource name = "Labels" and the Assembly i just want to get a string from
the resource file but keep getting:

_message "Could not find any resources appropriate for the specified
culture (or the neutral culture) in the given assembly. Make sure
\"Labels.resources\" was correctly embedded or linked into assembly
\"MyAsm.NameSpace\".\r\nbaseName: Labels locationInfo: <null> resource file
name: Labels.resources assembly: MyAsm, Version=1.0.1788.31693,
Culture=neutral, PublicKeyToken=null" string

the resources file is an embedding resource. Anyone got any ideas why?

TIA

Sam
 
The resources will probably be in a namespace. Most likely the root
namespace of the DLL or executable.

If you have an EXE called MyExe and the resources are called
Labels.MyLabelString then the fully qualified name for the string will be
"MyExe.LabelsMyLabelString"

As a sanity check you can write a little bit of code to dump out the
resource names before you do the final build. It lets you see all the names
in the assembly using the following code:

foreach(string s in this.GetType().Assembly.GetManifestResourceNames())
System.Diagnostics.Trace.WriteLine(s);

Whack this little bit of code in the form constructor somewhere and you'll
see all the fully qualified names in the assembly.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
thanks bob, i actually sussed it out late last night, but you're code
snippet is very welcome.

thanks for the response / advice

sam
 
Back
Top