System.Resources.ResourceManager.GetObject Method

Returns the value of the specified non-string resource.


public virtual object GetObject (string name)


The name of the resource to get.


The value of the resource localized for the caller's current culture settings. If an appropriate resource set exists but name cannot be found, the method returns null.


The ResourceManager.GetObject(string) method is used to retrieve non-string resources. These include values that belong to primitive data types such as int or double, bitmaps (such as a System.Drawing.Bitmap object), or custom serialized objects. Typically, the returned object must be cast (in C#) or converted (in Visual Basic) to an object of the appropriate type.

The returned resource is localized for the UI culture of the current thread, which is defined by the System.Globalization.CultureInfo.CurrentUICulture property. If the resource is not localized for that culture, the resource manager uses fallback rules to load an appropriate resource. If no usable set of localized resources is found, the System.Resources.ResourceManager falls back on the default culture's resources. If a resource set for the default culture is not found, the method throws a System.Resources.MissingManifestResourceException exception or, if the resource set is expected to reside in a satellite assembly, a System.Resources.MissingSatelliteAssemblyException exception. If the resource manager can load an appropriate resource set but cannot find a resource named name, the method returns null.

The ResourceManager.IgnoreCase property determines whether the comparison of name with the names of resources is case-insensitive (the default) or case-sensitive.


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 System.IO.FileLoadException exception might be thrown if an error was made deploying or installing a satellite assembly, or a System.Runtime.Serialization.SerializationException exception might be thrown if a user-defined type throws a user-defined exception when the type is deserialized.

Performance Considerations

If you call the erload:System.Resources.ResourceManager.GetObject method multiple times with the same name parameter, do not depend on the method returning a reference to the same object with each call. This is because the erload:System.Resources.ResourceManager.GetObject method can return a reference to an existing resource object in a cache, or it can reload the resource and return a reference to a new resource object.


Namespace: System.Resources
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0,,