This documentation is archived and is not being maintained.

PackagePart.GetRelationshipsByType Method

Returns a collection of the relationships that match a specified RelationshipType.

Namespace: System.IO.Packaging
Assembly: WindowsBase (in windowsbase.dll)

public PackageRelationshipCollection GetRelationshipsByType (
	string relationshipType
public PackageRelationshipCollection GetRelationshipsByType (
	String relationshipType
public function GetRelationshipsByType (
	relationshipType : String
) : PackageRelationshipCollection
You cannot use methods in XAML.



The RelationshipType of the relationships to locate and return in the collection.

Return Value

A collection of the relationships that match the specified relationshipType.

Exception typeCondition


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


relationshipType is an empty string.


The part has been deleted.


The Package is not open (Dispose or Close has been called).


The package is write-only (relationship information cannot be read).

The returned collection is never a null reference (Nothing in Visual Basic); however, the collection might contain zero elements if no relationships match the specified relationshipType that is defined for the part.

Any leading or trailing spaces in the relationshipType string are automatically trimmed.

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