This documentation is archived and is not being maintained.

LoaderOptimizationAttribute Class

Used to set the default loader optimization policy for the main method of an executable application.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public sealed class LoaderOptimizationAttribute : Attribute

The LoaderOptimizationAttribute can only be set on the main method for an executable application and is ignored on all other methods.

The LoaderOptimizationAttribute attribute is specified with a LoaderOptimization enumeration value, which tells the loader what type of application to optimize for: SingleDomain, MultiDomain, or MultiDomainHost.

This attribute is only a hint to the loader and does not affect program behavior.


If custom code access security policy is set for the AppDomain, by using the SetAppDomainPolicy property, and the AppDomain is created using the MultiDomain flag, the effect is the same as specifying the MultiDomainHost flag; that is, only assemblies in the GAC are shared. When this occurs, the loader does not throw an exception and the application does not experience the performance gains associated with the MultiDomain flag.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0