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)

static member ResourceAssembly : Assembly with 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 a null reference (Nothing in Visual Basic), 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 a null reference (Nothing in Visual Basic).

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.5.2, 4.5.1, 4.5, 4, 3.5 SP1, 3.0 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft