Class
ResourceHelper

Provides utility methods for loading and manipulating embedded assembly resources.

Definition

Namespace:Telerik.WinControls

Assembly:Telerik.WinControls.dll

Syntax:

cs-api-definition
public static class ResourceHelper

Inheritance: objectResourceHelper

Methods

CursorFromResource(Type, string)

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

Declaration

cs-api-definition
public static Cursor CursorFromResource(Type type, string resourceName)

Parameters

type

Type

A type from the assembly that contains the embedded resource.

resourceName

string

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.

Remarks

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.

ImageFromResource(Type, string)

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

Declaration

cs-api-definition
public static Bitmap ImageFromResource(Type type, string resourceName)

Parameters

type

Type

A type from the assembly that contains the embedded resource.

resourceName

string

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.

Remarks

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.