StronglyTypedResourceBuilder Class

Note: This class is new in the .NET Framework version 2.0.

Provides support for strongly-typed resources. This class cannot be inherited.

Namespace: System.Resources.Tools
Assembly: System.Design (in

public static class StronglyTypedResourceBuilder
public final class StronglyTypedResourceBuilder
public final class StronglyTypedResourceBuilder

The .NET Framework version 2.0 supports strongly-typed resources. Strongly-typed resource support is a compile-time feature that encapsulates access to resources by creating classes that contain a set of static, read-only (get) properties. This provides an alternative way to consume resources, rather than using the GetString and GetObject methods of the ResourceManager class.

Typically, resources separate code from content within an application. Creating and consuming these resources makes it easier to develop localizable applications.

In the .NET Framework, after the resources are created, they are usually consumed by using the ResourceManager class, which contains methods that provide access to culture-specific resources at run time. For more information about these processes, see Resources in Applications.

Strongly-typed resource support is an alternative to using the ResourceManager class to consume resources. The basic functionality is provided by the StronglyTypedResourceBuilder class (as well as a corresponding command-line option in the Resource File Generator (Resgen.exe)). The output of the Create method is a class that contains strongly-typed properties that match the resources that are referenced in the input parameter. This class provides strongly-typed, read-only access to the resources that are available in the file processed.

The following code example generates a class that is written in C#, is in the DemoApp namespace, is named DemoResources, and has properties that return the bitmap of a logo and the name of an application. The code example uses the following file, named demo.resx:

<data name="Logo" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/">
<value>[base 64 encoded value omitted here]
<data name="MyAppTitle">
<value>Demo Application</value>

Call the Create method with the following arguments:

StronglyTypedResourceBuilder.Create("demo.resx", "DemoResources", "DemoApp", new CSharpCodeProvider(), false, out errors[]) 

The Create method generates the following code:

using System;
using System.IO;
using System.Resources;

namespace DemoApp
public class DemoResources
protected static ResourceManager rm = new ResourceManager(typeof(className));
public static System.Resources.ResourceManager resourceManager 
get { return rm; }
public static System.Drawing.Bitmap Logo
get { return (System.Drawing.Bitmap)rm.GetObject(“logo”); }
    public static string MyAppTitle
      get { return rm.GetString("MyAppTitle"); }

In your application code, you can then use the class as follows:

this.Text = DemoResources.MyAppTitle;
System.Drawing.Bitmap bmp = DemoResources.Logo;


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0