Search code examples
c#asp.net.netresx

Not able to add Resx file in VS Web Solution


First time ever I am using Resx file. So below steps I did till now.

  1. Created empty Asp.net Solution.
  2. Added a Resx file with basic name value content.
  3. Add a web page and in code behind wrote below code:

    protected void Page_Load(object sender, EventArgs e) { ResourceManager rm = new ResourceManager("UsingRESX.Resource1", Assembly.GetExecutingAssembly()); String strWebsite = rm.GetString("Website", CultureInfo.CurrentCulture); // here I get the exception String strName = rm.GetString("Name"); form1.InnerText = "Website: " + strWebsite + "--Name: " + strName; }

But when I run the code I get exception as :

   Could not find any resources appropriate for the specified
 culture or the neutral culture.  Make sure "UsingRESX.Resource1.resources"
 was correctly embedded or linked into assembly "WebApplication1" at compile 
time, or that all the satellite assemblies required are loadable and fully signed.

Tutorial I followed for this exercise: Read Resx FIle

SO solution that I tried: SO Solution

enter image description here

enter image description here

enter image description here


Solution

  • Try adding

    var assembly = Assembly.GetExecutingAssembly();
    assembly.GetManifestResourceNames();
    

    and set a breakpoint. This will list all the embedded resources. Make sure you have the correct name. Sometimes the resource paths aren't entirely obvious.