How to get the value from global resource file in class library

2.8k Views Asked by At

I have two versions of visual studio 2010 installed on two laptops. One machine has VS2010 professional edition. another one has VS2010 Ultimate RTM.

I have created a website, where I would like to get the value of common messages from Resource file. (in App_GlobalResource Folder).

From aspx. I can read the resx file and set the value dynamically. Also, I am able to get the value from resx file at runtime.

My problem is when I trying to read the value from class Library, it is throwing error in RTM version (2010 ultimate), where as the below code is working fine in professional edition of VS2010.

I referenced Class library dll in my website.

read resx content from class library

The objective is I have created the above code in separate class file. So that i can read the value from resx file from both website and class library.

Any help is much appreciated. I want to know why the code works only on professional edition and not on RTM version?

Edited:

 public class Class1
 {
    public static string GetResourceFileValueByKey(string Key)
    {
     ResourceManager lang = new ResourceManager("Resources.GeneralInfos", Assembly.Load("App_GlobalResources"));
     string value = lang.GetString(Key);
     return value;
    }
 }
0

There are 0 best solutions below