Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DependencyAttribute Class

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)

'Declaration
<SerializableAttribute> _
<AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple := True)> _
Public NotInheritable Class DependencyAttribute _
	Inherits Attribute
'Usage
Dim instance As DependencyAttribute

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.

Imports System.Runtime.CompilerServices

<Assembly: DependencyAttribute("AssemblyA", LoadHint.Always)> 
<Assembly: DependencyAttribute("AssemblyB", LoadHint.Sometimes)> 
Module Program


    Sub Main(ByVal args() As String)
        Console.WriteLine("The DependencyAttribute attribute was applied.")
    End Sub 


End Module

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 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

Show:
© 2017 Microsoft