Windows apps
Collapse the table of content
Expand the table of content
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 Constructor (String, Assembly)

Updated: October 2010

Initializes a new instance of the ResourceManager class that looks up resources contained in files derived from the specified root name using the given Assembly.

Namespace:  System.Resources
Assembly:  mscorlib (in mscorlib.dll)

public ResourceManager(
	string baseName,
	Assembly assembly


Type: System.String
The root name of the resource file without its extension but including a fully qualified namespace name. For example, the root name for the resource file named "MyApplication.MyResource.en-US.resources" is "MyApplication.MyResource".
Type: System.Reflection.Assembly
The main assembly for the resources.


The baseName or assembly parameter is null.


assembly is not a run-time object.

The individual resource files should be contained in satellite assemblies with the invariant culture's.resource file contained in the main assembly. A satellite assembly is assumed to contain resources for a single culture specified in that assembly's manifest, and are loaded as necessary.

If the resource file identified by baseName cannot be found in assembly, the method instantiates a ResourceManager object, but the attempt to retrieve a specific resource throws an exception, typically a MissingManifestResourceException.

Notes to Implementers

This constructor uses the system-provided ResourceSet implementation. To use a custom resource file format, you should derive from the ResourceSet class, override GetDefaultReader and GetDefaultWriter, and pass that type to the ResourceManager constructor. Using a custom ResourceSet can be useful for controlling resource caching policy or supporting your own resource file format, but is generally not necessary.

The following example defines a new instance of the ResourceManager class that looks for executing assemblies under the item's root name. The code then checks for the culture of the currently executing thread and displays a culture-appropriate welcome message.

using System;
using System.Globalization;
using System.Threading;
using System.Resources;
using System.Reflection;

class Example
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
      // Create a resource manager to retrieve resources.
      ResourceManager rm = new ResourceManager("items",

      // Get the culture of the currently executing thread.
      // The value of ci will determine the culture of
      // the resources that the resource manager retrieves.
      CultureInfo ci = Thread.CurrentThread.CurrentCulture;

      // Retrieve the value of the string resource named 
      // "welcome", localized for the culture specified by ci.
      String str = rm.GetString("welcome", ci);
      outputBlock.Text += str + "\n";


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.




October 2010

Expanded the baseName parameter description and the Remarks section.

Customer feedback.

Community Additions

© 2018 Microsoft