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 (Type)

Initializes a new instance of the ResourceManager class that looks up resources in satellite assemblies based on information from the specified type object.

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

public ResourceManager(
	Type resourceSource


Type: System.Type

A type from which the resource manager derives all information for finding .resources files.


The resourceSource parameter is null.

Desktop Apps

In desktop apps, the resource manager uses the resourceSource parameter to load a particular resource file as follows:

  • If the NeutralResourcesLanguageAttribute attribute is not used to indicate that the resources of the default culture reside in a satellite assembly, the resource manager assumes that the resource file for the default culture is found in the same assembly as the type specified by the resourceSource parameter.

  • The resource manager assumes that the default resource file has the same base name as the type specified by the resourceSource parameter.

  • The resource manager uses the default ResourceSet class to manipulate the resource file.

For example, given a type named MyCompany.MyProduct.MyType, the resource manager looks for a .resources file named MyCompany.MyProduct.MyType.resources in the assembly that defines MyType.

In Visual Studio, the Resource Designer automatically generates code that defines an internal (in C#) or Friend (in Visual Basic) class whose name is the same as the base name of the .resources file for the default culture. This makes it possible to instantiate a ResourceManager object and couple it with a particular set of resources by getting a type object whose name corresponds to the name of the resource, because as long as the class is visible to the compiler, the resources must be as well. For example, if a .resources file is named Resource1, the following statement instantiates a ResourceManager object to manage the .resources file named Resource1:

ResourceManager rm = new ResourceManager(typeof(Resource1));

If you're not using Visual Studio, you can create a class with no members whose namespace and name are the same as that of the default .resources file. The example provides an illustration.

Windows Store Apps

Important noteImportant

Although the ResourceManager class is supported in Windows Store apps, we do not recommend its use. Use this class only when you develop Portable Class Library projects that can be used with Windows Store apps. To retrieve resources from Windows Store apps, use the Windows.ApplicationModel.Resources.ResourceLoader class instead.

In Windows Store apps, ResourceManager uses the resourceSource parameter to infer the assembly, base name, and the namespace where the resource items can be located within the app's package resource index (PRI) file. For example, given a type named MyCompany.MyProduct.MyType that is defined in MyAssembly, the resource manager looks for a resource set identifier named MyAssembly and looks for a scope MyCompany.MyProduct.MyType within that resource set. The resource manager searches for resource items under the default context (current culture, current high contrast setting, and so on) within this scope.

The following example uses the ResourceManager(Type) constructor to instantiate a ResourceManager object. It consists of resources compiled from .txt files for the English (en), French (France) (fr-FR), and Russian (Russia) (ru-RU) cultures. The example changes the current culture and current UI culture to English (United States), French (France), Russian (Russia), and Swedish (Sweden). It then calls the GetString(String) method to retrieve the localized string, which displays a greeting that depends on the time of day.

The example requires three text-based resource files, as listed in the following table. Each file includes string resources named Morning, Afternoon, and Evening.


File name

Resource name

Resource value




Good morning




Good afternoon




Good evening












Доброе утро



Добрый день



Добрый вечер

You can use the following batch file to compile the Visual Basic example and create an executable named Greet.exe. To compile with C#, change the compiler name from vbc to csc and the file extension from .vb to .cs.

resgen GreetingResources.txt
vbc Greet.vb /resource: GreetingResources.resources

md fr-FR
al /out:fr-FR\Greet.resources.dll /culture:fr-FR /embed: 

md ru-RU
al /out:ru-RU\Greet.resources.dll /culture:ru-RU /embed:

Here's the source code for the example (ShowDate.vb for the Visual Basic version or ShowDate.cs for the C# version of the code).

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


public class Example
   public static void Main()
      string[] cultureNames = {"en-US", "fr-FR", "ru-RU", "sv-SE" };
      DateTime noon = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 
                                   DateTime.Now.Day, 12,0,0);
      DateTime evening = new DateTime(DateTime.Now.Year, DateTime.Now.Month,
                                      DateTime.Now.Day, 18, 0, 0);                          

      ResourceManager rm = new ResourceManager(typeof(GreetingResources));

      foreach (var cultureName in cultureNames) {
         Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(cultureName);
         Console.WriteLine("The current UI culture is {0}", 
         if (DateTime.Now < noon)
            Console.WriteLine("{0}!", rm.GetString("Morning"));
         else if (DateTime.Now < evening)
            Console.WriteLine("{0}!", rm.GetString("Afternoon"));
            Console.WriteLine("{0}!", rm.GetString("Evening"));

   internal class GreetingResources
// The example displays output like the following: 
//       The current UI culture is en-US 
//       Good afternoon! 
//       The current UI culture is fr-FR 
//       Bonjour! 
//       The current UI culture is ru-RU 
//       Добрый день! 
//       The current UI culture is sv-SE 
//       Good afternoon!

In addition to defining an app class named Example, the source code defines an internal class whose name, GreetingResources, is the same as the base name of the resource files. This makes it possible to successfully instantiate a ResourceManager object by calling the ResourceManager(Type) constructor.

Notice that the output displays the appropriate localized string except when the current UI culture is Swedish (Sweden), in which case it uses English language resources. Because Swedish language resources are unavailable, the app uses the resources of the default culture, as defined by the NeutralResourcesLanguageAttribute attribute, instead.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
© 2015 Microsoft