DependencyAttribute(String, LoadHint) Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the DependencyAttribute class with the specified LoadHint value.
public:
DependencyAttribute(System::String ^ dependentAssemblyArgument, System::Runtime::CompilerServices::LoadHint loadHintArgument);
public DependencyAttribute (string dependentAssemblyArgument, System.Runtime.CompilerServices.LoadHint loadHintArgument);
new System.Runtime.CompilerServices.DependencyAttribute : string * System.Runtime.CompilerServices.LoadHint -> System.Runtime.CompilerServices.DependencyAttribute
Public Sub New (dependentAssemblyArgument As String, loadHintArgument As LoadHint)
Parameters
- dependentAssemblyArgument
- String
The dependent assembly to bind to.
Examples
The following 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.");
}
}
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
Remarks
The DependencyAttribute attribute gives the common language runtime hints on how tightly to bind to the dependency. The runtime uses these hints to help settle tradeoffs between lazy dependency load and efficient binding to the dependency. For example, hard binding allows the runtime to encode pointers to dependent native images, which results in a reduced working set. This attribute guides the runtime in making these decisions.