GetEntity Method
Collapse the table of content
Expand the table of content

XmlResolver.GetEntity Method

When overridden in a derived class, maps a URI to an object containing the actual resource.

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

public abstract Object GetEntity (
	Uri absoluteUri,
	string role,
	Type ofObjectToReturn
public abstract Object GetEntity (
	Uri absoluteUri, 
	String role, 
	Type ofObjectToReturn
public abstract function GetEntity (
	absoluteUri : Uri, 
	role : String, 
	ofObjectToReturn : Type
) : Object
Not applicable.



The URI returned from ResolveUri.


The current version does not use this parameter when resolving URIs. This is provided for future extensibility purposes. For example, this can be mapped to the xlink:role and used as an implementation specific argument in other scenarios.


The type of object to return. The current version only returns System.IO.Stream objects.

Return Value

A System.IO.Stream object or a null reference (Nothing in Visual Basic) if a type other than stream is specified.

Exception typeCondition


ofObjectToReturn is neither a null reference (Nothing in Visual Basic) nor a Stream type.


The specified URI is not an absolute URI.


absoluteUri is a null reference (Nothing in Visual Basic).


There is a runtime error (for example, an interrupted server connection).

This method is used when the caller wants to map a given URI into the object containing the actual resource that the URI represents. The type of object returned is negotiable; however, the implementation must always support System.IO.Stream.

Security noteSecurity Note:

Your application can mitigate memory Denial of Service threats to the GetEntity method by implementing a wrapping implemented IStream that limits the number of bytes read. This helps to guard against situations where malicious code attempts to pass an infinite stream of bytes to the GetEntity method.

See XmlUrlResolver.GetEntity for an example using this method.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

© 2015 Microsoft