本文整理匯總了VB.NET中System.Security.SecurityException類的典型用法代碼示例。如果您正苦於以下問題:VB.NET SecurityException類的具體用法?VB.NET SecurityException怎麽用?VB.NET SecurityException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了SecurityException類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
' 導入命名空間
Imports Microsoft.Win32
Imports System.Security
Imports System.Security.Permissions
Module Example
Public Sub Main()
Dim perms As New PermissionSet(CType(Nothing, PermissionSet))
perms.AddPermission(New UIPermission(PermissionState.Unrestricted))
perms.AddPermission(New RegistryPermission(PermissionState.None))
perms.PermitOnly()
Try
Dim key As RegistryKey = Registry.CurrentUser.CreateSubKey("MyCompany\\Applications")
Console.WriteLine("Registry key: {0}", key.Name)
Catch e As SecurityException
Console.WriteLine("Security Exception:\n\n{0}", e.Message)
End Try
End Sub
End Module
輸出:
Security Exception: Request for the permission of type 'System.Security.Permissions.RegistryPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.