LicenseManager-Klasse
Stellt Eigenschaften und Methoden bereit, um einer Komponente eine Lizenz hinzuzufügen und eine LicenseProvider-Klasse zu verwalten. Die Klasse kann nicht vererbt werden.
Namespace: System.ComponentModel
Assembly: System (in system.dll)
Syntax
'Declaration
Public NotInheritable Class LicenseManager
'Usage
Dim instance As LicenseManager
public sealed class LicenseManager
public ref class LicenseManager sealed
public final class LicenseManager
public final class LicenseManager
Hinweise
Die LicenseManager-Klasse stellt die folgenden static-Eigenschaften bereit: CurrentContext und UsageMode. Darüber hinaus stellt die Klasse die folgenden static-Methoden bereit: CreateWithContext, IsValid und Validate.
Wenn Sie eine Komponente erstellen und diese lizenzieren möchten, müssen Sie folgende Aktionen ausführen:
Geben Sie die LicenseProvider-Klasse an, indem Sie die Komponente mit LicenseProviderAttribute markieren.
Rufen Sie Validate oder IsValid im Konstruktor der Komponente auf. Validate löst eine LicenseException-Ausnahme aus, wenn versucht wird, eine Instanz ohne gültige Lizenz zu erstellen. IsValid löst keine Ausnahme aus.
Rufen Sie Dispose für jede erteilte Lizenz auf, wenn die Komponente freigegeben oder beendet wird.
Weitere Informationen über die Lizenzierung finden Sie unter Gewusst wie: Lizenzieren von Komponenten und Steuerelementen.
Hinweis
Das auf diese Klasse angewendete HostProtectionAttribute-Attribut besitzt den Resources-Eigenschaftenwert ExternalProcessMgmt. Das HostProtectionAttribute hat keine Auswirkungen auf Desktopanwendungen (die normalerweise durch Doppelklicken auf ein Symbol, Eingeben eines Befehls oder eines URL in einem Browser gestartet werden). Weitere Informationen finden Sie unter der HostProtectionAttribute-Klasse oder unter SQL Server-Programmierung und Hostschutzattribute.
Beispiel
Im folgenden Codebeispiel wird mithilfe der Validate-Methode ein lizenziertes Steuerelement erstellt. Diese Methode verwendet eine LicenseProvider-Klasse, die von der LicFileLicenseProvider-Klasse implementiert wird.
Imports System
Imports System.ComponentModel
Imports System.Windows.Forms
' Adds the LicenseProviderAttribute to the control.
<LicenseProvider(GetType(LicFileLicenseProvider))> _
Public Class MyControl
Inherits Control
' Creates a new, null license.
Private license As License = Nothing
Public Sub New()
' Adds Validate to the control's constructor.
license = LicenseManager.Validate(GetType(MyControl), Me)
' Insert code to perform other instance creation tasks here.
End Sub
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (license Is Nothing) Then
license.Dispose()
license = Nothing
End If
End If
End Sub
End 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;
}
}
}
}
// Adds the LicenseProviderAttribute to the control.
[LicenseProvider(LicFileLicenseProvider::typeid)]
public ref class MyControl: public Control
{
// Creates a new, null license.
private:
License^ license;
public:
MyControl()
{
// Adds Validate to the control's constructor.
license = LicenseManager::Validate( MyControl::typeid, this );
// Insert code to perform other instance creation tasks here.
}
public:
~MyControl()
{
if ( license != nullptr )
{
delete license;
license = nullptr;
}
}
};
import System.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
// Adds the LicenseProviderAttribute to the control.
/** @attribute LicenseProvider(LicFileLicenseProvider.class)
*/
public class MyControl extends Control
{
// Creates a new, null license.
private License license = null;
public MyControl()
{
// Adds Validate to the control's constructor.
license = LicenseManager.Validate(MyControl.class.ToType(), this);
// Insert code to perform other instance creation tasks here.
}
protected void Dispose(boolean disposing)
{
if (disposing) {
if (license != null) {
license.Dispose();
license = null;
}
}
}
}
Vererbungshierarchie
System.Object
System.ComponentModel.LicenseManager
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
Windows 98, Windows 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
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
LicenseManager-Member
System.ComponentModel-Namespace
License-Klasse
LicenseContext-Klasse
LicenseException-Klasse
LicenseProvider
LicenseProviderAttribute
LicFileLicenseProvider
LicenseUsageMode