Partager via


ProvideObjectAttribute Class

Informs Visual Studio that the VSPackage provides an object that can be created from the ILocalRegistryinterface. This class cannot be inherited.

Namespace:  Microsoft.VisualStudio.Shell
Assemblies:   Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)
  Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)
  Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)

Syntax

'Déclaration
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True, Inherited := True)> _
Public NotInheritable Class ProvideObjectAttribute _
    Inherits RegistrationAttribute
'Utilisation
Dim instance As ProvideObjectAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ProvideObjectAttribute : RegistrationAttribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true, Inherited = true)]
public ref class ProvideObjectAttribute sealed : public RegistrationAttribute
[<SealedAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)>]
type ProvideObjectAttribute =  
    class
        inherit RegistrationAttribute
    end
public final class ProvideObjectAttribute extends RegistrationAttribute

Remarks

When to Call

Apply the ProvideObjectAttribute attribute to your Microsoft.VisualStudio.Package-derived class if it provides an object that can be created from the ILocalRegistryinterface.

Basic Usage

The ProvideObjectAttribute class informs Visual Studio that it provides an object that can be created from the ILocalRegistryinterface. Always use this attribute rather than registering objects globally under the HKEY_CLASSES_ROOT\CLSID section of the registry. Use the ProvideObjectAttribute, to modify a Microsoft.VisualStudio.Package-derived class, or a class that implements IVsPackage.

This attribute class is only used to provide data for external registration tools like regpkg.exe. It does not have any effect on the run-time behavior of the VSPackage. For more information, see Registering VSPackages.

Notes

C# automatically appends the word "Attribute" to the name of any attribute class. In C# code, refer to this attribute as ProvideObject.

Registry Entries

  • The following registry entries are created by the ProvideObjectAttribute class:

  • <VSROOT>\CLSID\{ObjectGuid}

  • <VSROOT>\CLSID\{ObjectGuid}\@=ObjectType.FullName

  • <VSROOT>\CLSID\{ObjectGuid}\InprocServer32=mscoree.dll

  • <VSROOT>\CLSID\{ObjectGuid}\Class=ObjectType.FullName

  • <VSROOT>\CLSID\{ObjectGuid}\Assembly=ObjectType.Assembly.FullName

  • <VSROOT>\CLSID\{ObjectGuid}\ThreadingModel=Both

  • <VSROOT>\CLSID\{PackageGuid}\CodeBase=context.CodeBase

Examples

You can find implementations of the ProvideObjectAttribute class in the managed samples. The standard location for this and all other attributes used for automatic registration is adjacent to the implementation of the Microsoft.VisualStudio.Package class in VsPkg.cs, VsPkg.vb, or VsPkg.cpp, depending on the language used in the sample.

Inheritance Hierarchy

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

Thread Safety

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

See Also

Reference

ProvideObjectAttribute Members

Microsoft.VisualStudio.Shell Namespace