通过


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 ,指定可以使用许可对象的位置。

type
Type

一个 Type 表示请求 . 的 License组件。

instance
Object

请求 . License的对象。

allowExceptions
Boolean

如果当组件无法授予许可证时应引发 a,则为 />;否则为 >。

返回

有效的 License。 如果此方法找不到有效 License 或有效的 context 参数,则返回 null

注解

在设计时,该方法GetLicense查找名为myClassName.LIC的许可证文件,其中myClassName要创建的组件。FullName 此文件必须与包含组件的 .dll 文件位于同一目录中。

接下来,此方法根据方法中指定的 IsKeyValid 密钥检查许可证文件的第一行。 如果该键有效,则此行用作 LicenseKey.

适用于

另请参阅