XmlSecureResolver Constructor (XmlResolver, Evidence)

Initializes a new instance of the XmlSecureResolver class with the XmlResolver and System.Security.Policy.Evidence specified.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public XmlSecureResolver(
	XmlResolver resolver,
	Evidence evidence
)

Parameters

resolver
Type: System.Xml.XmlResolver

The XML resolver that is wrapped by the XmlSecureResolver.

evidence
Type: System.Security.Policy.Evidence

The evidence used to create the PermissionSet that will be applied to the underlying XmlResolver. The XmlSecureResolver calls the PermissionSet.PermitOnly method on the created PermissionSet before calling GetEntity on the underlying XmlResolver.

Here are some possible scenarios and the type of evidence to provide for each scenario:

  • If you are working in a fully trusted environment, use your assembly to create the evidence:

    Evidence myEvidence = this.GetType().Assembly.Evidence;
    XmlSecureResolver myResolver;
    myResolver = new XmlSecureResolver(new XmlUrlResolver(), myEvidence);
    
  • If you are working in a semi-trusted environment, you have code or data coming from an outside source, and you know the origin of the outside source and have a verifiable URI, use the URI to create the evidence:

    
    Evidence myEvidence = XmlSecureResolver.CreateEvidenceForUrl(sourceURI);
    XmlSecureResolver myResolver = new XmlSecureResolver(new XmlUrlResolver(), myEvidence);
    
  • If you are working in a semi-trusted environment and you have code or data coming from an outside source, but you don't know the origin of the outside source, either:

    Set the evidence parameter to null. This allows no access to resources.

    -or-

    If your application requires some access to resources, request evidence from the caller.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft