blog.scoreman.net

Using MOSS internal resources

Sometimes you may want to use standard MOSS resource strings that are not found in .resx files in the 12-hive or wwwroot. These strings can reside as compiled resources inside the SharePoint assemblies. Here are two helper functions to extract those resource strings.

private static string publishingAssemblyString = "Microsoft.SharePoint.Publishing.intl, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c";
private static string officeServerAssemblyString = "Microsoft.Office.Server.intl, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c";

public static string GetPublishingResource(CultureInfo info, string key)
{
    Assembly assembly = Assembly.Load(publishingAssemblyString);
    ResourceManager rm = new ResourceManager("Microsoft.SharePoint.Publishing.Strings", assembly);
    return rm.GetString(key, info);
}

public static string GetOfficeServerResource(CultureInfo info, string key)
{
    Assembly assembly = Assembly.Load(officeServerAssemblyString);
    ResourceManager rm = new ResourceManager("Microsoft.Office.Server.Strings", assembly);
    return rm.GetString(key, info);
}

Tags: ,

Leave a Reply