Export (0) Print
Expand All

Application.ResourceAssembly Property

Gets or sets the Assembly that provides the pack uniform resource identifiers (URIs) for resources in a WPF application.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)

public static Assembly ResourceAssembly { get; set; }

Property Value

Type: System.Reflection.Assembly
A reference to the Assembly that provides the pack uniform resource identifiers (URIs) for resources in a WPF application.

ExceptionCondition
InvalidOperationException

A WPF application has an entry assembly, or ResourceAssembly has already been set.

By default, WPF resources are resolved at run time with respect to the entry assembly, which is identified by the value returned from the GetEntryAssembly method.

The entry assembly is the assembly that is returned by GetEntryAssembly and could be the following:

  • The executable assembly in the default application domain.

  • The first assembly to be executed by calling ExecuteAssembly.

In the following cases, however, a WPF assembly cannot get a reference to the entry assembly:

  • An unmanaged (native) application hosts the WPF assembly.

  • A managed application hosts the WPF assembly by loading it into a new application domain using a method other than ExecuteAssembly.

In both of these cases, GetEntryAssembly returns null, and the WPF assembly's resources cannot be resolved. In these cases, ResourceAssembly can be set, once only, with a reference to the assembly that should be used to resolve resources.

ResourceAssembly can only be set once because it is unlikely that the resource assembly will change after the WPF assembly is loaded.

NoteNote

ResourceAssembly cannot be set when a WPF assembly can discover the entry assembly—that is, when GetEntryAssembly returns a reference to an assembly rather than null.

This property is thread safe and is available from any thread.

ResourceAssembly is introduced in the .NET Framework version 3.5. For more information, see .NET Framework Versions and Dependencies.

.NET Framework

Supported in: 4, 3.5 SP1, 3.0 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft