Hi,
Yes, it's possible to do that. Create a new project (Class Library), and add resources to it. The
Resources
class is an
internal
class, so you can't use it in another project. So, add a static class in your Class Library projects,
GetResources
:
public static class GetResources
{
public static object GetObject(string name)
{
return Properties.Resources.ResourceManager.GetObject(name);
}
public static string GetString(string name)
{
return Properties.Resources.ResourceManager.GetString(name);
}
public static System.Resources.ResourceManager GetResourceManager()
{
return Properties.Resources.ResourceManager;
}
}
And in your other project, add a reference to this Class Library. To get the value of the string "String1" in the resources of your Class Library, you can use this code:
string string1 = GetResources.GetString("String1");
To get an image "Image1", use this code:
Bitmap bmp = GetResources.GetObject("Image1") as Bitmap;
Hope this helps.