Export (0) Print
Expand All

LicenseException Class

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

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

[SerializableAttribute] 
public class LicenseException : SystemException
/** @attribute SerializableAttribute() */ 
public class LicenseException extends SystemException
SerializableAttribute 
public class LicenseException extends SystemException
Not applicable.

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 How to: License Components and Controls.

The following code 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 that 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.

This example requires 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.

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);    
}

try {
    License licTest = null;
    licTest = LicenseManager.Validate(Form1.class.ToType(), this);
}
catch (LicenseException licE) {
    Console.WriteLine(licE.get_Message());
    Console.WriteLine(licE.get_LicensedType());
    Console.WriteLine(licE.get_StackTrace());
    Console.WriteLine(licE.get_Source());
}

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

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

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft