CodeAccessPermission.RevertAll メソッド
アセンブリ: mscorlib (mscorlib.dll 内)




RevertAll メソッドを使用して、現在のフレームに対する以前のオーバーライドを元に戻す方法を次のコード例に示します。
Imports System Imports System.Security Imports System.Security.Permissions Imports System.IO Class UIPermissions Public Shared Sub Main() Try ' Create a new UIPermission that allows access only to OwnClipboard. Dim clipboardPermission As New UIPermission(UIPermissionClipboard.OwnClipboard) ' Deny access to OwnClipboard. Console.WriteLine("Denying access to OwnClipboard") clipboardPermission.Deny() ' Demand access to files in the specified path. DemandOwnClipboardAccess() ' Revert the Deny. Console.WriteLine("Reverting the Deny.") CodeAccessPermission.RevertDeny() DemandOwnClipboardAccess() ' Grant access only to OwnClipboard. Console.WriteLine("Granting permission only for OwnClipboard access.") clipboardPermission.PermitOnly() DemandAllClipboardAccess() ' Revert the PermitOnly with a call to RevertPermitOnly. Console.WriteLine("Reverting the PermitOnly.") CodeAccessPermission.RevertPermitOnly() DemandAllClipboardAccess() ' Permit access only to OwnClipboard. clipboardPermission.PermitOnly() DemandAllClipboardAccess() ' Revert the PermitOnly with a call to RevertAll. Console.WriteLine("Reverting the PermitOnly using RevertAll.") CodeAccessPermission.RevertAll() DemandAllClipboardAccess() Console.WriteLine("This sample completed successfully; " + _ "press Enter to exit.") Console.ReadLine() Catch e As Exception Console.WriteLine("Unexpected exception thrown: " + vbLf + e.ToString()) Console.ReadLine() End Try End Sub 'Main ' Determine whether OwnClipboard can be accessed. Private Shared Sub DemandOwnClipboardAccess() Try ' Create a new UIPermission that allows access to OwnClipboard. Dim clipboardPermission As New UIPermission(UIPermissionClipboard.OwnClipboard) ' Verify that callers higher in the stack have been granted ' the permission. Console.WriteLine("Demanding OwnClipboard access.") clipboardPermission.Demand() Console.WriteLine("The demand was successful") Catch ex As SecurityException Console.WriteLine("A security exception was thrown while " + _ "demanding OwnClipboard access permission " + vbLf) Console.WriteLine(ex.Message) Catch ex As Exception Console.WriteLine("A fatal exception occurred:" + vbLf + ex.ToString()) End Try End Sub 'DemandOwnClipboardAccess ' Determine whether OwnClipboard can be accessed. Private Shared Sub DemandAllClipboardAccess() Try ' Create a new UIPermission that allows access to OwnClipboard. Dim clipboardPermission As New UIPermission(UIPermissionClipboard.AllClipboard) ' Verify that callers higher in the stack have been granted ' the permission. Console.WriteLine("Demanding AllClipboard access.") clipboardPermission.Demand() Console.WriteLine("The demand was successful") Catch ex As SecurityException Console.WriteLine("A security exception was thrown while " + _ "demanding AllClipboard access permission " + vbLf) Console.WriteLine(ex.Message) Catch ex As Exception Console.WriteLine("A fatal exception occurred:" + vbLf + ex.ToString()) End Try End Sub 'DemandAllClipboardAccess End Class 'UIPermissions
using System; using System.Security; using System.Security.Permissions; using System.IO; class UIPermissions { public static void Main() { try { // Create a new UIPermission that allows access only to OwnClipboard. UIPermission clipboardPermission = new UIPermission(UIPermissionClipboard.OwnClipboard); // Deny access to OwnClipboard. Console.WriteLine("Denying access to OwnClipboard"); clipboardPermission.Deny(); // Demand access to files in the specified path. DemandOwnClipboardAccess(); // Revert the Deny. Console.WriteLine("Reverting the Deny."); CodeAccessPermission.RevertDeny(); DemandOwnClipboardAccess(); // Grant access only to OwnClipboard. Console.WriteLine("Granting permission only for OwnClipboard access."); clipboardPermission.PermitOnly(); DemandAllClipboardAccess(); // Revert the PermitOnly with a call to RevertPermitOnly. Console.WriteLine("Reverting the PermitOnly."); CodeAccessPermission.RevertPermitOnly(); DemandAllClipboardAccess(); // Permit access only to OwnClipboard. clipboardPermission.PermitOnly(); DemandAllClipboardAccess(); // Revert the PermitOnly with a call to RevertAll. Console.WriteLine("Reverting the PermitOnly using RevertAll."); CodeAccessPermission.RevertAll(); DemandAllClipboardAccess(); Console.WriteLine("This sample completed successfully; " + "press Enter to exit."); Console.ReadLine(); } catch (Exception e) { Console.WriteLine("Unexpected exception thrown: \n" + e.ToString()); Console.ReadLine(); } } // Determine whether OwnClipboard can be accessed. private static void DemandOwnClipboardAccess() { try { // Create a new UIPermission that allows access to OwnClipboard. UIPermission clipboardPermission = new UIPermission(UIPermissionClipboard.OwnClipboard); // Verify that callers higher in the stack have been granted // the permission. Console.WriteLine("Demanding OwnClipboard access."); clipboardPermission.Demand(); Console.WriteLine("The demand was successful"); } catch (SecurityException ex) { Console.WriteLine("A security exception was thrown while " + "demanding OwnClipboard access permission \n"); Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine("A fatal exception occurred:\n" + ex.ToString()); } } // Determine whether OwnClipboard can be accessed. private static void DemandAllClipboardAccess() { try { // Create a new UIPermission that allows access to OwnClipboard. UIPermission clipboardPermission = new UIPermission(UIPermissionClipboard.AllClipboard); // Verify that callers higher in the stack have been granted // the permission. Console.WriteLine("Demanding AllClipboard access."); clipboardPermission.Demand(); Console.WriteLine("The demand was successful"); } catch (SecurityException ex) { Console.WriteLine("A security exception was thrown while " + "demanding AllClipboard access permission \n"); Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine("A fatal exception occurred:\n" + ex.ToString()); } } }
using namespace System; using namespace System::Security; using namespace System::Security::Permissions; using namespace System::IO; ref class UIPermissions { public: static void Main() { try { // Create a new UIPermission that allows access only to OwnClipboard. UIPermission^ clipboardPermission = gcnew UIPermission( UIPermissionClipboard::OwnClipboard ); // Deny access to OwnClipboard. Console::WriteLine( L"Denying access to OwnClipboard" ); clipboardPermission->Deny(); // Demand access to files in the specified path. DemandOwnClipboardAccess(); // Revert the Deny. Console::WriteLine( L"Reverting the Deny." ); CodeAccessPermission::RevertDeny(); DemandOwnClipboardAccess(); // Grant access only to OwnClipboard. Console::WriteLine( L"Granting permission only for OwnClipboard access." ); clipboardPermission->PermitOnly(); DemandAllClipboardAccess(); // Revert the PermitOnly with a call to RevertPermitOnly. Console::WriteLine( L"Reverting the PermitOnly." ); CodeAccessPermission::RevertPermitOnly(); DemandAllClipboardAccess(); // Permit access only to OwnClipboard. clipboardPermission->PermitOnly(); DemandAllClipboardAccess(); // Revert the PermitOnly with a call to RevertAll. Console::WriteLine( L"Reverting the PermitOnly using RevertAll." ); CodeAccessPermission::RevertAll(); DemandAllClipboardAccess(); Console::WriteLine( L"This sample completed successfully; " L"press Enter to exit." ); Console::ReadLine(); } catch ( Exception^ e ) { Console::WriteLine( L"Unexpected exception thrown: \n{0}", e ); Console::ReadLine(); } } private: // Determine whether OwnClipboard can be accessed. static void DemandOwnClipboardAccess() { try { // Create a new UIPermission that allows access to OwnClipboard. UIPermission^ clipboardPermission = gcnew UIPermission( UIPermissionClipboard::OwnClipboard ); // Verify that callers higher in the stack have been granted // the permission. Console::WriteLine( L"Demanding OwnClipboard access." ); clipboardPermission->Demand(); Console::WriteLine( L"The demand was successful" ); } catch ( SecurityException^ ex ) { Console::WriteLine( L"A security exception was thrown while " L"demanding OwnClipboard access permission \n" ); Console::WriteLine( ex->Message ); } catch ( Exception^ ex ) { Console::WriteLine( L"A fatal exception occurred:\n{0}", ex ); } } // Determine whether OwnClipboard can be accessed. static void DemandAllClipboardAccess() { try { // Create a new UIPermission that allows access to OwnClipboard. UIPermission^ clipboardPermission = gcnew UIPermission( UIPermissionClipboard::AllClipboard ); // Verify that callers higher in the stack have been granted // the permission. Console::WriteLine( L"Demanding AllClipboard access." ); clipboardPermission->Demand(); Console::WriteLine( L"The demand was successful" ); } catch ( SecurityException^ ex ) { Console::WriteLine( L"A security exception was thrown while " L"demanding AllClipboard access permission \n" ); Console::WriteLine( ex->Message ); } catch ( Exception^ ex ) { Console::WriteLine( L"A fatal exception occurred:\n{0}", ex ); } } }; int main() { UIPermissions::Main(); }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からCodeAccessPermission.RevertAll メソッドを検索する場合は、下記のリンクをクリックしてください。

- CodeAccessPermission.RevertAll メソッドのページへのリンク