Share via


DependencyAttribute(String, LoadHint) 建構函式

定義

使用指定的 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.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 會提供 Common Language Runtime 提示,說明系結至相依性的方式。 運行時間會使用這些提示來協助解決延遲相依性負載與有效率的相依性系結之間的取捨。 例如,硬式系結可讓運行時間編碼相依原生影像的指標,這會導致減少的工作集。 此屬性會引導運行時間做出這些決策。

適用於