ResourceManager Constructor (String, Assembly)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
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.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- baseName
- 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".
- assembly
- Type: System.Reflection.Assembly
The main assembly for the resources.
| Exception | Condition |
|---|---|
| ArgumentNullException | The baseName or assembly parameter is Nothing. |
| ArgumentException | assembly is not a run-time object. |
This constructor uses the system-provided ResourceSet implementation. The individual 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 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.
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