DependencyAttribute(String, LoadHint) 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化一個以指定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
要綁定的附屬組件。
範例
以下範例說明原生影像生成服務總是綁定於 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 會給通用語言執行時提示,告訴你綁定相依關係的緊密程度。 執行時利用這些提示來幫助解決懶惰依賴負載與有效綁定依賴之間的權衡。 例如,硬綁定允許執行時編碼指向相依原生影像的指標,導致工作集減少。 此屬性引導執行時間在做出這些決策時。