PackageStore Class

Represents a collection of application-specific Package instances used in combination with PackWebRequest.

System.Object
  System.IO.Packaging.PackageStore

Namespace:  System.IO.Packaging
Assembly:  PresentationCore (in PresentationCore.dll)

public static class PackageStore

The PackageStore type exposes the following members.

  NameDescription
Public methodStatic memberAddPackageAdds a Package to the store.
Public methodStatic memberGetPackageReturns the Package with a specified URI from the store.
Public methodStatic memberRemovePackageRemoves the Package with a specified URI from the store.
Top

The PackageStore defines a reference collections of package that are open and active in the application. Packages added to the PackageStore are accessed is by their key URI value. The PackageStore supports three common uses:

  1. Accessing PackagePart data through PackWebRequest.

  2. The application obtaining an instance of a Package given the package's URI.

  3. Accessing packages that are created and stored in a MemoryStream.

To improve performance and minimize the overhead of repeated file open/close operations, the PackageStore is used to manage instances of packages accessed by PackWebRequest and directly by the application. When accessing data in a package, the Package address of a requested PackagePart Uri is first checked to see if the package is already defined and open in the PackageStore. If the package is defined as open in the PackageStore, requested parts can be accessed directly without repeatedly opening and closing the package for each request.

If your application opens a package with Package.Open, AddPackage can be called to add the package to the PackageStore. RemovePackage should later be called to remove the package from the PackageStore prior to calling Package.Close.

XPS packages opened with an XpsDocument constructor are automatically added and removed from the PackageStore when the document is created and disposed. (You do not need to call AddPackage or RemovePackage separately for XPS packages opened with XpsDocument constructors.)

The file I/O permissions of a package accessed through the PackageStore remains the same as the I/O permissions set on the package when it is opened. The PackageStore only provides references to the packages that have been added the store. It is up to the application to correctly open, update, and close each package.

Packages added to the PackageStore can be accessed in multithreaded environments when they are used in combination with a XAML parser such as XamlReader.Load.  When operating in a multithreaded environment, the application must lock the package before access.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft