WebPermission.FromXml(SecurityElement) Method

Definition

Reconstructs a WebPermission from an XML encoding.

public override void FromXml (System.Security.SecurityElement securityElement);

Parameters

securityElement
SecurityElement

The XML encoding from which to reconstruct the WebPermission.

Exceptions

The securityElement parameter is null.

securityElement is not a permission element for this type.

Examples

The following example creates a System.Security.SecurityElement, populates its attributes, and uses FromXml to transfer this information to an instance of WebPermission.


// Create  a WebPermission without permission on the protected resource.
WebPermission myWebPermission1 = new WebPermission(PermissionState.None);

// Create a SecurityElement by calling the ToXml method on the WebPermission 
// instance and display its attributes (which hold the XML encoding of 
// the WebPermission).
Console.WriteLine("Attributes and Values of the WebPermission are :");
myWebPermission1.ToXml().ToString();

// Create another WebPermission with no permission on the protected resource.
WebPermission myWebPermission2 = new WebPermission(PermissionState.None);

//Converts the new WebPermission from XML using myWebPermission1.
myWebPermission2.FromXml(myWebPermission1.ToXml());

Remarks

The FromXml method reconstructs a WebPermission from an XML encoding that is defined by the SecurityElement class.

Use the ToXml method to XML-encode the WebPermission, including state information.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also