Condividi tramite


ResourceManager.GetObject Method (String, CultureInfo)

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

Gets the value of the Object resource localized for the specified culture.

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

Syntax

'Declaration
Public Overridable Function GetObject ( _
    name As String, _
    culture As CultureInfo _
) As Object
public virtual Object GetObject(
    string name,
    CultureInfo culture
)

Parameters

  • culture
    Type: System.Globalization.CultureInfo
    The culture for which the resource is localized. Note that if the resource is not localized for this culture, the lookup will fall back using the culture's Parent property, stopping after checking in the neutral culture.
    If this value is nulla null reference (Nothing in Visual Basic), the CultureInfo is obtained using the culture's CurrentUICulture property.

Return Value

Type: System.Object
The value of the resource, localized for the specified culture. If a "best match" is not possible, nulla null reference (Nothing in Visual Basic) is returned.

Exceptions

Exception Condition
ArgumentNullException

The name parameter is nulla null reference (Nothing in Visual Basic).

MissingManifestResourceException

No usable set of resources have been found, and there are no neutral culture resources.

NotSupportedException

The resource depends on serialization.

Remarks

If the resource has not been localized for the specified culture, the resource that is returned is localized for a best match (this is accomplished using the culture's Parent property). Otherwise, nulla null reference (Nothing in Visual Basic) is returned.

If no usable set of resources has been found, the ResourceManager falls back on the neutral culture's resources, which are expected to be included in the main assembly. If an appropriate culture resource has not been found, a MissingManifestResourceException is thrown.

NoteNote:

The GetObject method is thread-safe.

Caution noteCaution:

This method can throw more exceptions than are listed. One reason this might occur is if a method that this method calls throws an exception. For example, a FileLoadException might be thrown if an error was made deploying or installing a satellite assembly.

Performance Considerations

If you call the GetObject method multiple times with the same name parameter, do not depend on the return value being a reference to the same object. This is because the GetObject method can return a reference to an existing resource object in a cache, or can reload the resource and return a reference to a new resource object.

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.