I am getting MissingManifestResourceException
exception when trying to access the resx file.
I have one code snippet which works fine and I have another one which does not work. I am not sure what is going on here.
Working Snippet
static void Main(string[] args)
{
//Keep an Eye on the first parameter I have passed, it has ".Lang" in it
var rm = new ResourceManager("ConsoleApp1.App_GlobalResources.Lang", Assembly.GetExecutingAssembly());
var ci = Thread.CurrentThread.CurrentCulture;
var a = rm.GetString("Name", ci);
Console.WriteLine("Hello World!");
}
Non Working Snippet:
static void Main(string[] args)
{
// Keep an eye on first parameter no ".Lang" here.
var rm = new ResourceManager("ConsoleApp1.App_GlobalResources", Assembly.GetExecutingAssembly());
var ci = Thread.CurrentThread.CurrentCulture;
var a = rm.GetString("Name", ci);
Console.WriteLine("Hello World!");
}
My Solution Structure:
Property of Lang.en-US file (Works Fine):
Property of en-US file (DO NOT Work):
Question 1: Why does Lang.en-US does not generate any .CS file, even then IT WORKS
Question 2: Why does a basic bare en-US.resx creates a .CS file and still does not work.
Link I looked into: SO LINK
Pic 1:
Pic 2:
Your Working example works as follow.
Lang.en-US.resx
and will default to Lang.resx
Your Non-Working example doesn't work, because you don't give it a virtual file prefix, but a folder path.
Solution: One Ideal situation, is using your Working with the following multiple language files.
Language folder (i.e: App_GlobalResources [bad name])
Code:
var rm = new ResourceManager("ConsoleApp1.App_GlobalResources.Lang", Assembly.GetExecutingAssembly());