Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ResourceManager trying to load .resources not .resx file

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?

like image 744
Adam Fox Avatar asked Sep 22 '09 15:09

Adam Fox


1 Answers

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;
like image 148
diimdeep Avatar answered Oct 03 '22 12:10

diimdeep