ResourcePermissionBase.AddPermissionAccess Method (ResourcePermissionBaseEntry)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Adds a permission entry to the permission.

Namespace:   System.Security.Permissions
Assembly:  System (in System.dll)

protected void AddPermissionAccess(
	ResourcePermissionBaseEntry entry
)

Exception Condition
ArgumentNullException

The specified ResourcePermissionBaseEntry is null.

InvalidOperationException

The number of elements in the ResourcePermissionBaseEntry.PermissionAccessPath property is not equal to the number of elements in the ResourcePermissionBase.TagNames property.

-or-

The ResourcePermissionBaseEntry is already included in the permission.

The following example shows the use of the AddPermissionAccess method to add a permission access entry during class initialization. This code example is part of a larger example provided for the ResourcePermissionBase class.

public MailslotPermission(MailslotPermissionAccess permissionAccess, string name, string machineName)
{
	SetNames();
	this.AddPermissionAccess(new MailslotPermissionEntry(permissionAccess, name, machineName));              
}

public MailslotPermission(MailslotPermissionEntry[] permissionAccessEntries) 
{
	SetNames();
	if (permissionAccessEntries == null)
		throw new ArgumentNullException("permissionAccessEntries");

	for (int index = 0; index < permissionAccessEntries.Length; ++index)
		this.AddPermissionAccess(permissionAccessEntries[index]);                          
}

.NET Framework
Available since 1.1
Return to top
Show: