开发者

How to statically access a .resx file

开发者 https://www.devze.com 2023-03-23 00:37 出处:网络
Currently I access my resource .resx file like this: ResourceManager manager = new ResourceManager(\"Resources.Messages\", Assembly.Load(\"App_GlobalResources\"));

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 an开发者_StackOverflowy code all I need to do is this:

string test = MessageResource.EmailBodyMagazine

How can I achieve this?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消