DependencyAttribute(String, LoadHint) 构造函数 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
使用指定的 LoadHint 值初始化 DependencyAttribute 类的新实例。
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.DependencyAttributePublic Sub New (dependentAssemblyArgument As String, loadHintArgument As LoadHint)参数
- dependentAssemblyArgument
- String
要绑定到的依赖程序集。
示例
以下示例指定本机映像生成服务始终绑定到 AssemblyA ,有时绑定到 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
注解
特性 DependencyAttribute 提供公共语言运行时提示绑定到依赖项的紧密程度。 运行时使用这些提示来帮助解决延迟依赖项负载与高效绑定到依赖项之间的权衡。 例如,硬绑定允许运行时对指向依赖本机映像的指针进行编码,这会导致工作集减少。 此属性指导运行时做出这些决策。