ResourceManager trying to load .resources not .resx file

Adam Fox picture Adam Fox · Sep 22, 2009 · Viewed 28.1k times · Source

I am trying to load a resx file in my .net website using:

ResourceManager rm = new ResourceManager( "Project.Resource", Assembly.GetExecutingAssembly() );

The Resource.resx file is in the folder App_LocalResources and is set to be embedded in assembly on build.

When I try to access the resx file using:

rm.GetString( "key" ); or rm.GetString( "key", culture );

I get an error message:

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

Notice the .resources ... any ideas on what is going on here?

Answer

diimdeep picture diimdeep · Oct 23, 2012

To load .resx into ResourceManager you need specify namespace

var rm = new ResourceManager("Namespace.ResxName", Assembly.GetAssembly());

or you can get ResourceManager for free if set Access Modifier inside Managed Resource Editor to Internal or Public, after that VS will generate ResxName.Designer.cs

var rm = ResxName.ResourceManager;