Export (0) Print
Expand All

DefaultDependencyAttribute Class

Provides a hint to the common language runtime (CLR) indicating how likely a dependency is to be loaded. This class is used in a dependent assembly to indicate what hint should be used when the parent does not specify the DependencyAttribute attribute. This class cannot be inherited.

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

[SerializableAttribute]
[AttributeUsageAttribute(AttributeTargets.Assembly)]
public sealed class DefaultDependencyAttribute : Attribute

This attribute is used by the Native Image Generator (Ngen.exe) to generate native assembly images.

Apply the DefaultDependencyAttribute attribute to a dependent assembly to determine the preferred default binding.

A dependency that is likely to be loaded (Always) will cause Ngen.exe to bind to that dependency. Using this hint allows Ngen.exe to generate code that will result in a reduced working set and improved throughput but at the cost of always loading the dependency when the parent assembly is loaded.

When you apply the DependencyAttribute attribute to an assembly with a value of Default, the native image generation service consults the dependent assembly for its preferred default binding, which is specified by the DefaultDependencyAttribute attribute.

The following code example demonstrates how to apply the DefaultDependencyAttribute attribute to an assembly to specify that the dependency is likely to be loaded.

using System;
using System.Runtime.CompilerServices;

[assembly: DefaultDependencyAttribute(LoadHint.Always)]
class Program
{

    static void Main(string[] args)
    {

        Console.WriteLine("The DefaultDependencyAttribute attribute was applied.");

    }
}

System.Object
  System.Attribute
    System.Runtime.CompilerServices.DefaultDependencyAttribute

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

Community Additions

ADD
Show:
© 2014 Microsoft