DependencyAttribute(String, LoadHint) 构造函数

定义

使用指定的DependencyAttribute值初始化类的新实例LoadHint

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)

参数

dependentAssemblyArgument
String

要绑定到的依赖程序集。

loadHintArgument
LoadHint

其中一个 LoadHint 值。

示例

以下示例指定本机映像生成服务始终绑定到 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 属性提供公共语言运行时提示,说明绑定到依赖项的紧密程度。 运行时使用这些提示来帮助解决延迟依赖项负载与对依赖项的有效绑定之间的权衡。 例如,硬绑定允许运行时对指向依赖本机图像的指针进行编码,这会导致工作集减少。 此属性指导运行时做出这些决策。

适用于