ProvideProfileAttribute Class

 

Apply this attribute to independent objects used to implement a VSPackage's Visual Studio settings support.

Namespace:   Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.14.0 (in Microsoft.VisualStudio.Shell.14.0.dll)

System.Object
  System.Attribute
    Microsoft.VisualStudio.Shell.RegistrationAttribute
      Microsoft.VisualStudio.Shell.ProvideProfileAttribute

<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True,
	Inherited := True)>
Public NotInheritable Class ProvideProfileAttribute
	Inherits RegistrationAttribute

NameDescription
System_CAPS_pubmethodProvideProfileAttribute(Type, String, String, Int16, Int16, Boolean)

Initializes a new instance of ProvideProfileAttribute.

NameDescription
System_CAPS_pubpropertyAlternateParent

Gets or sets the name of a different category in the profile.

System_CAPS_pubpropertyCategoryName

Gets the canonical nonlocalized name of the Visual Studio settings category.

System_CAPS_pubpropertyCategoryResourceID

Gets the name resource ID for a Visual Studio settings category.

System_CAPS_pubpropertyDescriptionResourceID

Gets the localized resource ID of the description of this page of the profile.

System_CAPS_pubpropertyGroupName

Gets the nonlocalized name of this group.

System_CAPS_pubpropertyGroupResourceID

Gets or sets the localized resource ID of the group to which this page belongs.

System_CAPS_pubpropertyIsToolsOptionPage

Gets whether this is also a Tools Options page.

System_CAPS_pubpropertyMigrationType

Sets the migration action to take for this category.

System_CAPS_pubpropertyObjectName

Gets the canonical nonlocalized name of this page in the profile.

System_CAPS_pubpropertyObjectNameResourceID

Gets the localized resource ID of the name of this page in the profile.

System_CAPS_pubpropertyObjectType

Gets the type of the page.

System_CAPS_pubpropertyResourcePackageGuid

Gets or sets the GUID of a package providing the resource strings.

System_CAPS_pubpropertyTypeId

Gets the current instance of this attribute.(Inherited from RegistrationAttribute.)

Apply the ProvideProfileAttribute attribute to classes implementing a VSPackage when there is a class that implements Visual Studio settings functionality for the VSPackage, allowing it to save and retrieve VSPackage state information.

System_CAPS_noteNote

Classes implementing IProfileManager, must also implement IComponent, which can be done by deriving the class from Component.

Applies to

VSPackages using the Visual Studio settings mechanism through classes that implement the IProfileManager or DialogPage interfaces.

Repeatable

Yes

Required attributes

DefaultRegistryRootAttribute, Note   If the class implementing Visual Studio settings also provides a Tools Options page, ProvideOptionPageAttribute is also required.

Invalid attributes

None

This attribute is used only for registration purposes and does not affect runtime behavior.

ProvideProfileAttribute registers a class implementing IProfileManager or DialogPage as providing support for persisting part or all of the VSPackage's state through the Visual Studio settings mechanism. The state information persisted by the implementing class is referred to as a Visual Studio settings category, and its defining entry in the registry is referred to as a Custom Settings Point.

When a user selects the Import/Export Settings command on the Tools menu to save Visual Studio settings, the classes registered by ProvideProfileAttribute are instantiated by the IDE and used to save the settings.

Because of this:

  • Visual Studio settings support should be implemented on its own object and not on the VSPackage itself.

  • A class implementing Visual Studio settings may support only one Visual Studio settings category as defined in Custom Settings Point.

However, a single VSPackage may support several Visual Studio settings categories as defined multiple Custom Settings Points as long as:

  • Each Visual Studio settings category is implemented in a separate class..

  • Each class implementing Visual Studio settings is registered as supporting the VSPackage by its own instance of ProvideProfileAttribute.

    System_CAPS_noteNote

    This differs from the COM-based implementations where a class implementing Visual Studio settings may support multiple Custom Settings Points.

An instance of ProvideProfileAttribute:

  • Uniquely identifies a Custom Settings Point's Visual Studio settings category with the GUID obtained from the Type of the class implementing Visual Studio settings.

  • Sets a Visual Studio settings category's name, both its canonical, nonlocalized name used in registry entries and its localized name resources.

  • Indicates if the Visual Studio settings supporting class's implementation of ProvideProfileAttribute supports a Tools Options page (for more information on supporting Tools Options page, see Options Pages).

For more information on creating and applying instances of ProvideProfileAttribute, see the example below and ProvideProfileAttribute.

In the example below, two instances of ProvideProfileAttribute are applied to a VSPackage implementation to define the two classes as providing Visual Studio settings support for the VSPackage implemented by the class MyPackage.

  1. Because the implementation of the page named "DesignerOptionsPage" is derived from DialogPage, it can support Visual Studio settings and Tools Options pages, and is registered as providing both:

    • An implementation of a Tools Options page, which is registered through the instance ProvideOptionPageAttribute. For more information on supporting Tools Options pages, see ProvideOptionPageAttribute.

    • An implementation that supports persisting the state of Tools Options pages, which is indicated by the final argument to the ProvideProfileAttribute constructor.

  2. The class named "PersistedDesignerState" is registered as providing just Visual Studio settings support, saving and retrieving remaining state information of the VSPackage named "MyPackage" by implementing IProfileManager.

using Microsoft.VisualStudio.Shell;
namespace Example
{
[DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\8.0")] 
[ProvideOptionPage(typeof(DesignerOptionsPage), "MyDesigner", "OptionPage", 1000, 1001, true)] 
[ProvideProfileAttribute(typeof(DesignerOptionsPage), "MyDesigner", "OptionPage", 1002, 1003, true)]
[ProvideProfileAttribute(typeof(PersistCurrentDesign), "MyDesigner","CurrentDesign", 1004, 1005, false)]
[Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")]
public class MyPackage : Package
{
//Implementation here
}

[Guid("YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY")]
internal class DesignerOptionsPage: DialogPage {
//Implementation here
}

[Guid("ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ")]
internal class PersistCurrentDesign: IProfileManager {
//Implementation here
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: