語言

LicFileLicenseProvider.GetLicense 方法

定義

如果有該元件實例的授權,會回傳一個授權。

public:
 override System::ComponentModel::License ^ GetLicense(System::ComponentModel::LicenseContext ^ context, Type ^ type, System::Object ^ instance, bool allowExceptions);
public override System.ComponentModel.License? GetLicense(System.ComponentModel.LicenseContext context, Type type, object? instance, bool allowExceptions);
public override System.ComponentModel.License GetLicense(System.ComponentModel.LicenseContext context, Type type, object instance, bool allowExceptions);
override this.GetLicense : System.ComponentModel.LicenseContext * Type * obj * bool -> System.ComponentModel.License
Public Overrides Function GetLicense (context As LicenseContext, type As Type, instance As Object, allowExceptions As Boolean) As License

參數

context
LicenseContext

LicenseContext A 指定你可以在哪裡使用授權物件。

type
Type

A Type 代表請求 的 License元件。

instance
Object

一個請求 .License

allowExceptions
Boolean

true 若當元件無法獲得授權時應拋出 a LicenseException ;否則,則 false。

傳回

一個有效的 License。 若此方法找不到有效 License 或有效 context 參數,則回傳 null。

備註

在設計時,該 GetLicense 方法會尋找一個名為 myClassName.LIC的授權檔案,其中 myClassName 是 FullName 要建立元件的 。 這個檔案必須與包含該元件的 .dll 檔案在同一個目錄中。

接著,此方法會將授權檔案的第一行與方法 IsKeyValid 中指定的金鑰進行檢查。 若鍵數有效,則此行被用作 LicenseKey。

適用於

另請參閱