<Application> Element (.NET Native)

Serves as a container for application-wide types and type members whose metadata is available for reflection at run time, and applies runtime reflection policy to all the program elements in an app.

<Directives> Element <Application> Element (rd.xml)

Syntax

<Application Activate="policy_setting"
             Browse="policy_setting"
             Dynamic="policy_setting"
             Serialize="policy_setting"
             DataContractSerializer="policy_setting"
             DataContractJsonSerializer="policy_setting"
             XmlSerializer="policy_setting"
             MarshalObject="policy_setting"
             MarshalDelegate="policy_setting"
             MarshalStructure="policy_setting" />

Attributes and Elements

The following sections describe attributes, child elements, and parent elements. In the Child Elements table, policy refers to the kind of metadata that is made available for particular program elements at run time.

Attributes

Attribute Attribute type Description
Activate Reflection Optional attribute. Controls runtime access to constructors to enable activation of instances.
Browse Reflection Optional attribute. Controls querying for information about or enumerating the types, but does not enable any dynamic access at run time.
Dynamic Reflection Optional attribute. Controls runtime access to all type members, including constructors, methods, fields, properties, and events, to enable dynamic programming.
Serialize Serialization Optional attribute. Controls runtime access to constructors, fields, and properties, to enable type instances to be serialized and deserialized by libraries such as the Newtonsoft JSON serializer.
DataContractSerializer Serialization Optional Attribute. Controls policy for serialization that uses the System.Runtime.Serialization.DataContractSerializer class.
DataContractJsonSerializer Serialization Optional Attribute. Controls policy for JSON serialization that uses the System.Runtime.Serialization.Json.DataContractJsonSerializer class.
XmlSerializer Serialization Optional Attribute. Controls policy for XML serialization that uses the System.Xml.Serialization.XmlSerializer class.
MarshalObject Interop Optional Attribute. Controls policy for marshaling reference types to Windows Runtime and COM.
MarshalDelegate Interop Optional Attribute. Controls policy for marshaling delegate types as function pointers to native code.
MarshalStructure Interop Optional Attribute. Controls policy for marshaling structures to native code.

All attributes

Value Description
policy_setting The setting for this policy to apply to the types in the app. Possible values are All, Auto, Excluded, Public, PublicAndInternal, Required Public, Required PublicAndInternal, and Required All. For more information, see Runtime Directive Policy Settings.

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.
<Method> Applies policy to a method on a particular type.
<MethodInstantiation> Applies policy to a constructed generic method.
<Property> Applies policy to a property on a particular type.
<Field> Applies policy to a field on a particular type.
<Event> Applies policy to an event on a particular type.

Parent Elements

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

Remarks

The <Directives> element can contain zero or one <Application> element. Multiple <Application> elements in a single reflection directives file are not supported.

The <Application> element can be used in one of two ways:

  • As a container to define the program elements whose metadata is needed at run time. In this case, the <Application> element need not have any attributes. At compile time, compiler tools search all libraries, including .NET Framework core libraries, for program elements identified by child elements of the <Application> element. In contrast, compiler tools search only the library designated by the <Library> element for program elements identified by the child elements of <Library>.

  • As an element that sets application-wide policy for reflection, serialization, and interop. The attributes of the <Application> element define application-wide policy, which may be overridden by the child elements defined by the <Application> or <Library> element.

See also