Edit

Share via


MetadataLoadContext.CoreAssembly Property

Definition

Gets or sets the assembly that denotes the "system assembly" that houses the well-known types such as Int32.

public:
 property System::Reflection::Assembly ^ CoreAssembly { System::Reflection::Assembly ^ get(); };
public System.Reflection.Assembly CoreAssembly { get; }
member this.CoreAssembly : System.Reflection.Assembly
Public ReadOnly Property CoreAssembly As Assembly

Property Value

An Assembly instance.

Remarks

The core assembly is treated differently than other assemblies because references to these well-known types do not include the assembly reference, unlike normal types.

Typically, this assembly is named "System.Runtime", "mscorlib", or "netstandard".

The CoreAssembly is determined by passing the coreAssemblyName parameter to the MetadataLoadContext constructor, which in turn passes it to the MetadataAssemblyResolver.Resolve method.

If no coreAssemblyName argument was specified in the constructor of MetadataLoadContext, then default values are used, including "mscorlib", "System.Runtime" and "netstandard".

The designated core assembly does not need to contain the core types directly. It can type forward them to other assemblies. Thus, it is perfectly permissible to use the mscorlib facade as the designated core assembly.

Note that System.Runtime is not an ideal core assembly because it excludes some of the interop-related pseudo-custom attribute types such as DllImportAttribute. However, it can serve if you have no interest in those attributes. The CustomAttributes API will skip those attributes if the core assembly does not include the necessary types.

If a core assembly cannot be found, the constructor of MetadataLoadContext throws an exception.

Applies to