NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

LicenseManager Class

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

Object
   LicenseManager

[Visual Basic]
NotInheritable Public Class LicenseManager
[C#]
public sealed class LicenseManager
[C++]
public __gc __sealed class LicenseManager
[JScript]
public class LicenseManager

Remarks

LicenseManager provides the following static (in Visual Basic Shared) properties: CurrentContext and UsageMode. The class also provides the following static (Shared) methods: CreateWithContext, IsValid, Validate.

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

  1. Specify the LicenseProvider by marking the component with a LicenseProviderAttribute.
  2. Call Validate or IsValid in the constructor of the component. Validate will throw a LicenseException when it tries to create an instance without a valid license. IsValid will not throw an exception.
  3. Dispose any license that is granted when the component is disposed or finalized.

For more information on licensing, see TBD.

Requirements

Namespace: System.ComponentModel

Assembly: System.dll

Example [C#]

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

[C#]

// Add the LicenseProviderAttribute to the control.

{LicenseProvider[typeof[LicFileLicenseProvider}}]
public class MyControl : RichControl {

   // Create a new null license.

   private License license = null;

   public MyControl () {

      // Add Validate to the control's constructor.

      license = LicenseManager.Validate(typeof(MyControl), this);

      // Perform other instantiation tasks.

   }

   public override void Dispose() {
      if (license != null) {
         license.Dispose();
         license = null;
      }
   }

   protected override void Finalize() {
      Dispose();
      base.Finalize();
   }
}

See Also

LicenseManager Members | System.ComponentModel Namespace | License | LicenseContext | LicenseException | LicenseProvider | LicenseProviderAttribute | LicFileLicenseProvider | LicenseUsageMode