Runtime Directive Policy Settings

Note

This topic refers to the .NET Native Developer Preview, which is pre-release software. You can download the preview from the Microsoft Connect website (requires registration).

Runtime directive policy settings for .NET Native determine the availability of metadata for types and type members at run time. Without the necessary metadata, operations that rely on reflection, serialization and deserialization, or marshaling of .NET Framework types to COM or the Windows Runtime can fail and throw an exception. Most common exceptions are MissingMetadataException and (in the case of interop) MissingInteropDataException.

Runtime policy settings are controlled by a runtime directives (.rd.xml) file. Each runtime directive defines policy for a particular program element, such as an assembly (the <Assembly> element), a type (the <Type> element), or a method (the <Method> element). The directive includes one or more attributes that define the reflection policy types, the serialization policy types, and the interop policy types discussed in the next section. The value of the attribute defines the policy setting.

Policy types

Runtime directives files recognize three categories of policy types: reflection, serialization, and interop.

Policy settings

Each policy type can be set to one of the values listed in the following table. Note that elements that represent type members support a different set of policy settings than other elements.

Policy setting Description Assembly, Namespace, Type, and TypeInstantiation elements Event, Field, Method, MethodInstantiation, and Property elements
All Enables the policy for all types and members that the .NET Native tool chain doesn't remove.
Auto Specifies that the default policy should be used for the policy type for that program element. This is identical to omitting a policy for that policy type. Auto is typically used to indicate that policy is inherited from a parent element.
Excluded Specifies that the policy is disabled for a particular program element. For example, the runtime directive:

<Type Name="BusinessClasses.Person" Browse="Excluded" Dynamic="Excluded" />

specifies that metadata for the BusinessClasses.Person class isn't available either to browse or to dynamically instantiate and modify Person objects.
Included Enables a policy if metadata for the parent type is available.
Public Enables the policy for public types or members, unless the tool chain determines that the type or member is unnecessary and therefore removes it. This setting differs from Required Public, which ensures that metadata for public types and members is always available even if the tool chain determines that it's unnecessary.
PublicAndInternal Enables the policy for public and internal types or members, unless the tool chain determines that the type or member is unnecessary and therefore removes it. This setting differs from Required PublicAndInternal, which ensures that metadata for public and internal types and members is always available even if the tool chain determines that it's unnecessary.
Required Specifies that the policy for a member is enabled and that metadata will be available even if the member appears to be used.
Required Public Enables the policy for public types or members, and ensures that metadata for public types and members is always available. This setting differs from Public, which makes metadata for public types and members available only if the tool chain determines that it's necessary.
Required PublicAndInternal Enables the policy for public and internal types or members, and ensures that metadata for public and internal types and members is always available. This setting differs from PublicAndInternal, which makes metadata for public and internal types and members available only if the tool chain determines that it's necessary.
Required All Requires the tool chain to keep all types and members whether or not they're used, and enables policy for them.

See Also

Runtime Directives (rd.xml) Configuration File Reference
Runtime Directive Elements