LicenseManager Class
TOC
Collapse the table of content
Expand the table of content

LicenseManager Class

 

Provides properties and methods to add a license to a component and to manage a LicenseProvider. This class cannot be inherited.

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

System.Object
  System.ComponentModel.LicenseManager

[HostProtectionAttribute(SecurityAction.LinkDemand, ExternalProcessMgmt = true)]
public sealed class LicenseManager

NameDescription
System_CAPS_pubpropertySystem_CAPS_staticCurrentContext

Gets or sets the current LicenseContext, which specifies when you can use the licensed object.

System_CAPS_pubpropertySystem_CAPS_staticUsageMode

Gets the LicenseUsageMode which specifies when you can use the licensed object for the CurrentContext.

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticCreateWithContext(Type, LicenseContext)

Creates an instance of the specified type, given a context in which you can use the licensed instance.

System_CAPS_pubmethodSystem_CAPS_staticCreateWithContext(Type, LicenseContext, Object[])

Creates an instance of the specified type with the specified arguments, given a context in which you can use the licensed instance.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticIsLicensed(Type)

Returns whether the given type has a valid license.

System_CAPS_pubmethodSystem_CAPS_staticIsValid(Type)

Determines whether a valid license can be granted for the specified type.

System_CAPS_pubmethodSystem_CAPS_staticIsValid(Type, Object, License)

Determines whether a valid license can be granted for the specified instance of the type. This method creates a valid License.

System_CAPS_pubmethodSystem_CAPS_staticLockContext(Object)

Prevents changes being made to the current LicenseContext of the given object.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticUnlockContext(Object)

Allows changes to be made to the current LicenseContext of the given object.

System_CAPS_pubmethodSystem_CAPS_staticValidate(Type)

Determines whether a license can be granted for the specified type.

System_CAPS_pubmethodSystem_CAPS_staticValidate(Type, Object)

Determines whether a license can be granted for the instance of the specified type.

The LicenseManager class provides the following static properties: CurrentContext and UsageMode. The class also provides the following static methods: CreateWithContext, IsValid, and Validate.

When you create a component that you want to license, you must do the following:

  1. Specify the LicenseProvider by marking the component with a LicenseProviderAttribute.

  2. Call Validate or IsValid in the constructor of the component. Validate throws a LicenseException when it tries to create an instance without a valid license. IsValid does not throw an exception.

  3. Call Dispose on any license that is granted when the component is disposed or finalized.

For more information on licensing, see How to: License Components and Controls.

The following code example creates a licensed control using the Validate method. It uses a LicenseProvider that is implemented by the LicFileLicenseProvider class.

using System;
using System.ComponentModel;
using System.Windows.Forms;


// Adds the LicenseProviderAttribute to the control.
[LicenseProvider(typeof(LicFileLicenseProvider))]
public class MyControl : Control 
{

   // Creates a new, null license.
   private License license = null;

   public MyControl () 
   {

      // Adds Validate to the control's constructor.
      license = LicenseManager.Validate(typeof(MyControl), this);

      // Insert code to perform other instance creation tasks here.
   }

   protected override void Dispose(bool disposing) 
   {
      if(disposing)
      {
         if (license != null) 
         {
            license.Dispose();
            license = null;
         }
      }
   }

}

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft