LicFileLicenseProvider.GetLicense Method (LicenseContext, Type, Object, Boolean)


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

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

public override License GetLicense(
	LicenseContext context,
	Type type,
	object instance,
	bool allowExceptions


Type: System.ComponentModel.LicenseContext

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

Type: System.Type

A Type that represents the component requesting the License.

Type: System.Object

An object that requests the License.

Type: System.Boolean

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

Return Value

Type: System.ComponentModel.License

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

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.

.NET Framework
Available since 1.1
Return to top