insanepaul
insanepaul

Reputation: 197

How to statically access a .resx file

Currently I access my resource .resx file like this:

ResourceManager manager = new ResourceManager("Resources.Messages", Assembly.Load("App_GlobalResources"));
        string test = manager.GetString("EmailBodyMagazine", System.Globalization.CultureInfo.CurrentCulture); 

I'm trying to create a static class MessageResource that accesses the resource file so that to call this class from any code all I need to do is this:

string test = MessageResource.EmailBodyMagazine

How can I achieve this?

Upvotes: 3

Views: 4059

Answers (1)

Cornel
Cornel

Reputation: 4708

Open the .resx file using VS2008. From the .resx editor toolbar change the 'Access Modifier' to 'Public'. This will allow access to the resources from any asssembly that references the App_GlobalResources assembly (ex: Messages.EmailBodyMagazine).

You can also find a quick tutorial here.

Upvotes: 3

Related Questions