<Library> Element (.NET Native)

Defines the assembly that contains types and type members whose metadata is available for reflection at run time.

<Directives> Element <Library> Element

Syntax

<Library Name="assembly_name" />

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description
Name Required attribute. Specifies the name of an assembly. Child elements of this <Library> element define the runtime reflection policy for types and type members found in this assembly.

Name attribute

Value Description
assembly_name The simple name of the assembly, without its file extension. This attribute corresponds to the AssemblyName.Name property. For example, the name of an assembly named Extensions.dll is "Extensions". See the Remarks section for a special form of assembly_name that supports conditional inclusion of metadata from the assembly.

Child Elements

Element Description
<Assembly> Applies policy to all the types in a particular assembly.
<Namespace> Applies policy to all the types in a particular namespace.
<Type> Applies policy to a particular type, such as a class or structure.
<TypeInstantiation> Applies policy to a constructed generic type. For example, a <TypeInstantiation> element could be used to define policy for a List<String> type.

Parent Elements

Element Description
<Directives> The root element of a runtime directives file.

Remarks

The <Directives> element can contain zero, one, or more <Library> elements.

The <Library> element serves as a container to define the program elements whose metadata is needed at run time; this element doesn't express policy. At compile time, compiler tools search only the library designated by the <Library> element for program elements identified by its child elements. In contrast, compiler tools search all libraries, including.NET Framework core libraries, for program elements identified by child elements of the <Application> element.

<Library> directives may be conditionally utilized. If the name of the <Library> element starts and ends with an asterisk (*), the <Library> directive has an effect only if the assembly specified between the asterisks is referenced by the app. For example, the following runtime directive applies only if the Utilities.dll assembly is referenced by the app.

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Library Name="*Utilities*">
   ...
  </Library>
</Directives>

See also