[ACCEPTED]-ResourceManager trying to load .resources not .resx file-resourcemanager

Accepted answer
Score: 21

To load .resx into ResourceManager you need 4 specify namespace

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

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

var rm = ResxName.ResourceManager;
Score: 5

There's surprisingly simple way of reading 4 resource by string:

ResourceNamespace.ResxFileName.ResourceManager.GetString("ResourceKey")

It's clean and elegant 3 solution for reading resources by keys where 2 "dot notation" cannot be used (for instance 1 when resource key is persisted in the database).

Score: 3

I think the way you are using ResourceManager 7 is wrong. See this post.

Also note, when you 6 open Visual Studio command prompt, & run 5 resgen.exe, it says its used to convert 4 resource files from one format to another 3 (i.e. resx to resources). I think, you will 2 need to convert your file to resources from 1 resx & then load it using resourceManager.

Score: 3

I'm not sure which version of .NET Framework 6 are you using.

Try channging the way how 5 you bring the ResourceManager to life.

ResourceManager rm = 
     new ResourceManager("Project.Resource", 
                         System.Reflection.Assembly.Load("App_LocalResources"));

It 4 should work.

This is also exposed as a static 3 property of the automatically generated 2 .designer.cs class of the concrete resorce 1 manager.

More Related questions