LicFileLicenseProvider.GetLicense 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
如果有該元件實例的授權,會回傳一個授權。
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 指定你可以在哪裡使用授權物件。
- allowExceptions
- Boolean
true 若當元件無法獲得授權時應拋出 a LicenseException ;否則,則 false。
傳回
一個有效的 License。 若此方法找不到有效 License 或有效 context 參數,則回傳 null。
備註
在設計時,該 GetLicense 方法會尋找一個名為 myClassName.LIC的授權檔案,其中 myClassName 是 FullName 要建立元件的 。 這個檔案必須與包含該元件的 .dll 檔案在同一個目錄中。
接著,此方法會將授權檔案的第一行與方法 IsKeyValid 中指定的金鑰進行檢查。 若鍵數有效,則此行被用作 LicenseKey。