Επεξεργασία

Κοινή χρήση μέσω


Application.ResourceAssembly Property

Definition

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

public:
 static property System::Reflection::Assembly ^ ResourceAssembly { System::Reflection::Assembly ^ get(); void set(System::Reflection::Assembly ^ value); };
public static System.Reflection.Assembly ResourceAssembly { get; set; }
static member ResourceAssembly : System.Reflection.Assembly with get, set
Public Shared Property ResourceAssembly As Assembly

Property Value

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

Exceptions

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

Remarks

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.

Note

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 Versions and Dependencies.

Applies to