Export (0) Print
Expand All

LicenseException Class

Represents the exception thrown when a component cannot be granted a license.

For a list of all members of this type, see LicenseException Members.

System.Object
   System.Exception
      System.SystemException
         System.ComponentModel.LicenseException

[Visual Basic]
Public Class LicenseException
   Inherits SystemException
[C#]
public class LicenseException : SystemException
[C++]
public __gc class LicenseException : public SystemException
[JScript]
public class LicenseException extends SystemException

Thread Safety

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

Remarks

The LicenseManager.Validate method throws LicenseException when a component cannot obtain a valid license. This occurs when a component is either not licensed, or is licensed, but cannot be granted a valid license.

For more information on licensing, see Licensing Components and Controls.

Example

[Visual Basic, C#, C++] The following example shows how to catch a LicenseException and interpret its content. In the sample, the application calls the Validate method for a System.Windows.Forms.Form, which is not licensed. Upon catching the exception, the sample fetches the respective error message, the type of component that was not granted a license, the stack trace, and the origin of the exception.

[Visual Basic, C#, C++] This example assumes that you have specified the LicenseProvider by marking the System.Windows.Forms.Form with a LicenseProviderAttribute attribute. For more information on how to do this, see the LicenseManager class.

[Visual Basic] 
Try
    Dim licTest As License
    licTest = LicenseManager.Validate(GetType(Form1), Me)
Catch licE As LicenseException
    Console.WriteLine(licE.Message)
    Console.WriteLine(licE.LicensedType)
    Console.WriteLine(licE.StackTrace)
    Console.WriteLine(licE.Source)
End Try

[C#] 
try {
    License licTest = null;
    licTest = LicenseManager.Validate(typeof(Form1), this);
}

catch(LicenseException licE) {
    Console.WriteLine(licE.Message);
    Console.WriteLine(licE.LicensedType);
    Console.WriteLine(licE.StackTrace);
    Console.WriteLine(licE.Source);    
}

[C++] 
try {
    License* licTest = 0;
    licTest = LicenseManager::Validate(__typeof(Form1), this);
}

catch(LicenseException* licE) {
    Console::WriteLine(licE->Message);
    Console::WriteLine(licE->LicensedType);
    Console::WriteLine(licE->StackTrace);
    Console::WriteLine(licE->Source);    
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.ComponentModel

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

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

Show:
© 2014 Microsoft