Partager via


ResourceManager Constructor (String, Assembly, Type)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
Public Sub New ( _
    baseName As String, _
    assembly As Assembly, _
    usingResourceSet As Type _
)
public ResourceManager(
    string baseName,
    Assembly assembly,
    Type usingResourceSet
)

Parameters

  • baseName
    Type: System.String
    The root name of the resource file without its extension and along with any fully qualified namespace name. For example, the root name for the resource file named "MyApplication.MyResource.en-US.resources" is "MyApplication.MyResource".
  • usingResourceSet
    Type: System.Type
    The type of the custom ResourceSet to use. If nulla null reference (Nothing in Visual Basic), the default runtime ResourceSet object is used.

Exceptions

Exception Condition
ArgumentException

usingResourceset is not a derived class of ResourceSet.

ArgumentNullException

The baseName or assembly parameter is nulla null reference (Nothing in Visual Basic).

Remarks

The individual resource files should be contained in satellite assemblies with the invariant culture's .resources 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.

You can specify a ResourceSet implementation to be used. If you do not need a specific ResourceSet implementation but would like to use a custom resource file format, you should derive from the ResourceSet class, override the GetDefaultReader method, and pass that type to this constructor.

NoteNote:

The usingResourceSet parameter is used to support your own resource format, and will commonly be nulla null reference (Nothing in Visual Basic). This is different from the constructor that takes a Type only.

Platform Notes

Silverlight for Windows Phone Silverlight for Windows Phone

ResourceManager(String, Assembly, Type), throws NotSupportedException when the usingResourceSet parameter is null..

Version Information

Silverlight

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

Platforms

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

Change History

Date

History

Reason

October 2010

Expanded the baseName parameter description and the Remarks section.

Customer feedback.