Επεξεργασία

Κοινή χρήση μέσω


LicFileLicenseProvider.GetLicense Method

Definition

Returns a license for the instance of the component, if one is available.

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

Parameters

context
LicenseContext

A LicenseContext that specifies where you can use the licensed object.

type
Type

A Type that represents the component requesting the License.

instance
Object

An object that requests the License.

allowExceptions
Boolean

true if a LicenseException should be thrown when a component cannot be granted a license; otherwise, false.

Returns

A valid License. If this method cannot find a valid License or a valid context parameter, it returns null.

Remarks

At design time, the GetLicense method looks for a license file named myClassName.LIC, where myClassName is the FullName of the component to create. This file must be in the same directory as the .dll file that contains the component.

Next, this method checks the first line of the license file against a key specified in the IsKeyValid method. If the key is valid, this line is used as the LicenseKey.

Applies to

See also