ResourceManager Constructor (String, Assembly)
Updated: October 2010
Assembly: mscorlib (in mscorlib.dll)
- 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 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.
Imports System.Globalization Imports System.Threading Imports System.Resources Imports System.Reflection Class Example Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) ' Create a resource manager to retrieve resources. Dim rm As New ResourceManager("items", _ [Assembly].GetExecutingAssembly()) ' Get the culture of the currently executing thread. ' The value of ci will determine the culture of ' the resources that the resource manager retrieves. Dim ci As CultureInfo = Thread.CurrentThread.CurrentCulture ' Retrieve the value of the string resource named ' "welcome" localized for the culture specified by ci. Dim str As [String] = rm.GetString("welcome", ci) outputBlock.Text &= str & vbCrLf End Sub End Class
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.