ProvideBindingPathAttribute Class

This attribute allows the assemblies in your Visual Studio Package or Extension to be used by other packages and extensions. It adds the directory where your package is installed to the Visual Studio probing list, which is used to resolve assembly references.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.VisualStudio.Shell.RegistrationAttribute
      Microsoft.VisualStudio.Modeling.Shell.ProvideBindingPathAttribute

Namespace:  Microsoft.VisualStudio.Modeling.Shell
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.Shell.10.0 (in Microsoft.VisualStudio.Modeling.Sdk.Shell.10.0.dll)

Syntax

声明
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True, Inherited := True)> _
Public NotInheritable Class ProvideBindingPathAttribute _
    Inherits RegistrationAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ProvideBindingPathAttribute : RegistrationAttribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true, Inherited = true)]
public ref class ProvideBindingPathAttribute sealed : public RegistrationAttribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)>]
type ProvideBindingPathAttribute =  
    class
        inherit RegistrationAttribute
    end
public final class ProvideBindingPathAttribute extends RegistrationAttribute

The ProvideBindingPathAttribute type exposes the following members.

Constructors

  Name Description
Public method ProvideBindingPathAttribute

Top

Properties

  Name Description
Public property SubPath An optional SubPath to set after $PackageFolder$. This should be used if the assemblies to be probed reside in a different directory than the pkgdef file.
Public property TypeId (Inherited from RegistrationAttribute.)

Top

Methods

  Name Description
Public method Equals Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Returns the hash code for this instance. (Inherited from Attribute.)
Protected method GetPackageRegKeyPath (Inherited from RegistrationAttribute.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IsDefaultAttribute When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public method Match When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Register Register the component path (or optionally a sub-path of the component path) as an additional path that the assembly manager in Visual Studio will probe when attempting to resolve assemblies. Called when the package is installed. (Overrides RegistrationAttribute.Register(RegistrationAttribute.RegistrationContext).)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method Unregister Unregister the component path as a binding path. Called when the package is uninstalled. (Overrides RegistrationAttribute.Unregister(RegistrationAttribute.RegistrationContext).)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method _Attribute.GetIDsOfNames Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfo Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfoCount Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.Invoke Provides access to properties and methods exposed by an object. (Inherited from Attribute.)

Top

Remarks

备注

This information is applicable to Visual Studio 2010. An alternative method might be provided in later releases.

If you want the assemblies in your package or extension to be visible to other extensions, you should apply this attribute to your package class or to your assembly. For example:

[ProvideBindingPath] 
public class MyVsPackage : Microsoft.VisualStudio.Shell.Package 
{ ... }

If you are using Visualization and Modeling SDK to create a domain-specific language (DSL), the attribute is automatically applied in DslPackage\Package.cs.

If you are not building a DSL, include the following file in your project:

%VSSDKInstallDir%\VisualStudioIntegration\Common\Source\CSharp\RegistrationAttributes\ProvideBindingPathAttribute.cs

If your package's assemblies are in a sub-directory relative to the .pkgdef file, you can use this variant:

[ProvideBindingPath(SubPath="SubFolder1")] 
public class MyPackage : Microsoft.VisualStudio.Shell.Package 
{ ... }

You can use more than one ProvideBindingPath attribute if you want to specify several directories.

警告

Because this attribute extends the list of folders where Visual Studio looks for assemblies, you might notice a drop in performance if you install many packages that have this attribute.

How the Package Binding Path attribute works

This attribute generates an entry in your package’s .pkgdef file, which you can find in the build folder. This in turn creates an entry in the registry when your package is installed on a target computer. The registry entry provides a path that should be probed for candidate assemblies when other assemblies are loaded.

For example, the .pkgdef entry is similar to this:

[$RootKey$\BindingPaths\your package GUID] "$PackageFolder$"=""

When the package is installed on a target computer, a registry entry is added in HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0_Config\BindingPaths\your package GUID. The entry includes a string attribute that indicates the installation folder of the package.

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

Microsoft.VisualStudio.Modeling.Shell Namespace

Package

Other Resources

How to: Load Dependent Assemblies

Deploying Domain-Specific Language Solutions