Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Caching Data
 Caching Data Objects
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual Studio Tools for the Microsoft Office System
Caching Data Objects

Note Required applications

The features in this topic are available only if you have the required applications installed.

For more information, see Features Available by Product Combination.

  • One of these development environments:

    VSTO 2005

    -or-

    Visual Studio Team System

  • Microsoft Office 2003

You can cache a data object in a Microsoft Visual Studio 2005 Tools for the Microsoft Office System solution by adding the CachedAttribute attribute to an instance of a data type that meets certain requirements. Many common data types in the .NET Framework meet these requirements, including String, DataSet and DataTable. If you want to cache instances of data types that you create, the data types must meet these requirements.

Requirements for Data Objects to be Cached

To be cacheable, a data object must:

  • Be a read/write public field or property, not read-only or write-only.

  • Not be an indexer or other parameterized property.

In addition, the data object must meet the requirements of XmlSerializer. The data object must:

  • Be a public type.

  • Have a public constructor with no parameters.

  • Not execute code that requires additional security privileges.

  • Expose only read/write public properties (other properties will be ignored).

  • Not expose multi-dimensional arrays (nested arrays are accepted).

  • Not return interfaces from properties and fields.

  • Not implement IDictionary if a collection.

Any data item that has a null value is not cached. When you create a variable to hold a data object, you must initialize the value of the variable or it is not cached.

Option for Greater Control

You have the option of implementing ICachedType in your data object to give greater control over caching behavior. For example, you can implement this interface if you want to control how the user is notified when the object has been changed.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker