Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DependencyAttribute Class

Note: This class is new in the .NET Framework version 2.0.

Indicates when a dependency is to be loaded by the referring assembly. This class cannot be inherited.

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

[SerializableAttribute] 
[AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple=true)] 
public sealed class DependencyAttribute : Attribute
/** @attribute SerializableAttribute() */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple=true) */ 
public final class DependencyAttribute extends Attribute
SerializableAttribute 
AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple=true) 
public final class DependencyAttribute extends Attribute

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

Apply the DependencyAttribute attribute to a dependent assembly with a value of the LoadHint enumeration to specify when a referring assembly is to load a dependency.

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.

The following code example specifies that the native image generation service always binds to AssemblyA and sometimes binds to AssemblyB.

using System;
using System.Runtime.CompilerServices;

[assembly: DependencyAttribute("AssemblyA", LoadHint.Always)]
[assembly: DependencyAttribute("AssemblyB", LoadHint.Sometimes)]

class Program
{
    
    static void Main(string[] args)
    {

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

    }
}

System.Object
   System.Attribute
    System.Runtime.CompilerServices.DependencyAttribute
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 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.