LicFileLicenseProvider.GetLicense 方法

定義

傳回元件的執行個體 (Instance) 授權 (如果有的話)。

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,指定您可以使用授權物件的位置。

type
Type

Type,表示要求 License 的元件。

instance
Object

要求 License 的物件。

allowExceptions
Boolean

如果元件無法取得授權時應該擲回 LicenseException,則為 true,否則為 false

傳回

有效的 License。 如果這個方法無法找到有效的 License 或有效的 context 參數,就會傳回 null

備註

在設計時間, GetLicense 方法會尋找名為 的 myClassName.LIC授權檔案,其中 myClassNameFullName 要建立之元件的 。 此檔案必須與包含元件的 .dll 檔案位於相同的目錄中。

接下來,此方法會根據方法中指定的 IsKeyValid 密鑰,檢查授權檔案的第一行。 如果索引鍵有效,則會使用這一行做為 LicenseKey

適用於

另請參閱