LicenseException クラス
アセンブリ: System (system.dll 内)
構文
コンポーネントが有効なライセンスを取得できない場合、LicenseManager.Validate メソッドは LicenseException をスローします。この例外は、コンポーネントがライセンス付きでないか、またはライセンス付きだが有効なライセンスが与えられなかった場合にスローされます。
ライセンスの詳細については、「方法 : コンポーネントおよびコントロールのライセンス処理を行う」を参照してください。
メモ |
---|
このクラスに適用される HostProtectionAttribute 属性の Resources プロパティの値は、SharedState です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的には、アイコンをダブルクリック、コマンドを入力、またはブラウザに URL を入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラスのトピックまたは「SQL Server プログラミングとホスト保護属性」を参照してください。 |
LicenseException をキャッチし、その内容を解釈するコード例を次に示します。このサンプルでは、アプリケーションは、ライセンス付きでない System.Windows.Forms.Form に対して Validate メソッドを呼び出します。例外をキャッチしたときに、このサンプルはそれぞれのエラー メッセージ、ライセンス付きでないコンポーネントの種類、スタック トレース、および例外の発生源をフェッチします。
この例では、System.Windows.Forms.Form を LicenseProviderAttribute 属性でマークして、LicenseProvider を指定していることが必要です。この方法の詳細については、LicenseManager クラスのトピックを参照してください。
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
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); }
System.Exception
System.SystemException
System.ComponentModel.LicenseException
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- LicenseException クラスのページへのリンク