New to Telerik UI for WinForms? Start a free 30-day trial

Provides utility methods for loading and manipulating embedded assembly resources.

ResourceHelper contains static methods for accessing embedded resources from assemblies, particularly images and cursors that are embedded as manifest resources. It provides safe resource loading with proper exception handling and resource disposal.

Key features include:

  • Safe loading of embedded bitmap images with automatic memory management
  • Cursor creation from embedded cursor resource files
  • Proper exception handling with debug output for troubleshooting
  • Automatic resource stream disposal to prevent memory leaks
  • Assembly-based resource resolution using type information

This class is commonly used throughout Telerik controls for loading embedded images, icons, cursors, and other resources that are compiled into the assembly as manifest resources.

Definition

Namespace:Telerik.WinControls

Assembly:Telerik.WinControls.dll

Syntax:

C#
public static class ResourceHelper

Inheritance: objectResourceHelper

Methods

Creates a new cursor from an embedded resource in the assembly containing the specified type.

C#
public static Cursor CursorFromResource(Type type, string resourceName)
Parameters:typeType

A type from the assembly that contains the embedded resource.

resourceNamestring

The fully qualified name of the embedded cursor resource (including namespace).

Returns:

Cursor

A new Cursor instance loaded from the embedded resource, or null if the resource could not be found or loaded.

This method safely loads a cursor from an embedded manifest resource by:

  1. Obtaining the assembly from the specified type
  2. Opening a stream to the manifest resource
  3. Creating a cursor directly from the stream
  4. Ensuring proper resource disposal regardless of outcome

The resource should be a valid cursor file (.cur) embedded as a manifest resource. The resource name should include the full namespace path, similar to other embedded resources.

Exception handling ensures that any loading errors are logged to debug output for troubleshooting, while maintaining application stability by returning null on failure.

Creates a new bitmap image from an embedded resource in the assembly containing the specified type.

C#
public static Bitmap ImageFromResource(Type type, string resourceName)
Parameters:typeType

A type from the assembly that contains the embedded resource.

resourceNamestring

The fully qualified name of the embedded resource (including namespace).

Returns:

Bitmap

A new Bitmap instance loaded from the embedded resource, or null if the resource could not be found or loaded.

This method safely loads a bitmap image from an embedded manifest resource by:

  1. Obtaining the assembly from the specified type
  2. Opening a stream to the manifest resource
  3. Creating a temporary bitmap from the stream
  4. Creating a new bitmap copy to ensure proper memory management
  5. Disposing of temporary resources and streams

The resource name should include the full namespace path. For example, if an image is in the "Resources" folder of a project with namespace "MyProject", the resource name would be "MyProject.Resources.image.png".

Exception handling ensures that any loading errors are logged to debug output, and all resources are properly disposed of regardless of success or failure.