ResourceManager Constructor (String, Assembly)
Initializes a new instance of the ResourceManager class that looks up resources contained in files with the specified root name using the given assembly.
Assembly: mscorlib (in mscorlib.dll)
- Type: System::String
The root name of the resource file without its extension but including any 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 individual culture-specific resource files should be contained in satellite assemblies, with the default 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 is loaded as necessary.
To retrieve resources from .resources files directly instead of retrieving them from assemblies, you must call the CreateFileBasedResourceManager method instead to instantiate a ResourceManager object.
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. For information about diagnosing the cause of the exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section of the ResourceManager class topic.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 uses a simple non-localized "Hello World" application to illustrate the constructor. The following shows the contents of a text file named ExampleResources.txt. When the application is compiled, the resource is embedded in the main application assembly.
The text file can be converted to a binary resource file by using the Resource File Generator (ResGen.exe) at the command line as follows:
The following example provides the executable code that instantiates a ResourceManager object, prompts the user to enter a name, and displays a greeting.
It can be compiled by using the following command in Visual Basic:
vbc Example.vb /resource:ExampleResources.resources
or by using the following command in C#:
csc Example.cs /resource:ExampleResources.resources
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2