The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ResourceManager Class

Provides convenient access to culture-specific resources at runtime.

For a list of all members of this type, see ResourceManager Members.


[Visual Basic]
Public Class ResourceManager
public class ResourceManager
public __gc class ResourceManager
class ResourceManager

Thread Safety

This type is safe for multithreaded operations.


The ResourceManager class looks up culture-specific resources, provides resource fallback when a localized resource does not exist, and supports resource serialization.

Using the methods of ResourceManager, a caller can access the resources for a particular culture using the GetObject and GetString methods. By default, these methods return the resource for the culture determined by the current cultural settings of the thread that made the call. (See Thread.CurrentUICulture for more information.) A caller can use the ResourceManager.GetResourceSet method to obtain a ResourceSet, which represents the resources for a particular culture, ignoring culture fallback rules. You can then use the ResourceSet to access the resources, localized for that culture, by name.

Ideally, you should create resources for every language, or at least a meaningful subset of the language. The resource file names follow the naming convention basename.cultureName.resources, where basename is the name of the application or the name of a class, depending on the level of detail you want. The CultureInfo 's Name property is used to determine the cultureName. A resource for the neutral culture (returned by InvariantCulture) should be named basename.resources.

For example, suppose that an assembly has several resources in a resource file with the basename "MyResources". These resource files will have names such as "MyResources.ja-JP.resources", "", "MyResources.zh-CHS.resources", or "", which contain resources respectively for Japanese, German, simplified Chinese, and French (Belgium). The default resource file should be named MyResources.resources. The culture-specific resource files are commonly packaged in satellite assemblies for each culture. The default resource file should be in your main assembly.

Now suppose that a ResourceManager has been created to represent the resources with this basename. Using the ResourceManager, you can obtain a ResourceSet that encapsulates "MyResources.ja-JP.resources" by calling GetResourceSet(new CultureInfo ("ja-JP"), TRUE, FALSE). Or, if you know that "MyResources" contains a resource named "TOOLBAR_ICON", you can obtain the value of that resource localized for Japan by calling GetObject("TOOLBAR_ICON", new CultureInfo("ja-JP")).

While not strictly necessary for the most basic uses of the ResourceManager, publicaly shipping assemblies should use the SatelliteContractVersionAttribute to support versioning your main assembly without redeploying your satellites, and the NeutralResourcesLanguageAttribute to avoid looking up a satellite assembly that might never exist. For more information about versioning support for satellite assemblies, see Retrieving Resources in Satellite Assemblies. To learn more about creating satellite assemblies, see Creating Satellite Assemblies. For assistance with localization of Windows Forms dialogs, see the Windows Forms Resource Editor (Winres.exe) tool in the Microsoft .NET Framework SDK.

To learn more about setting up and creating resources, see Resources in Applications.

CAUTION   Using standalone .resources files in an ASP.NET application will break XCOPY deployment, because the resources remain locked until they are explicitly released by the ReleaseAllResources method. If you want to deploy resources into ASP.NET applications, you should compile your .resources into satellite assemblies.
CAUTION   Resources marked as private are accessible only in the assembly in which they are placed. Because a satellite assembly contains no code, resources private to it become unavailable through any mechanism. Therefore, resources in satellite assemblies should always be public so that they are accessible from your main assembly. Resources embedded in your main assembly are accessible to your main assembly, whether private or public.


Namespace: System.Resources

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: Mscorlib (in Mscorlib.dll)

See Also

ResourceManager Members | System.Resources Namespace | CultureInfo | SatelliteContractVersionAttribute | Developing World-Ready Applications