ProvideBindingRedirectionAttribute Class

Definition

This attribute registers a set of values that define a binding redirection. These values will be merged at startup into the CLR runtime configuration.

For example: [$RootKey$\RuntimeConfiguration\dependentAssembly\bindingRedirection{5C48C732-5C7F-40f0-87A7-05C4F15BC8C3}] "Name"="AssemblyName" "PublicKeyToken"="19ab8cb7287f414" "Culture"="neutral" "CodeBase"="$PackageFolder$\AssemblyName.dll" "OldVersion"="1.0.0.0" "NewVersion"="2.0.0.0"

public ref class ProvideBindingRedirectionAttribute sealed : Microsoft::VisualStudio::Shell::ProvideDependentAssemblyAttribute
public ref class ProvideBindingRedirectionAttribute sealed : Microsoft::VisualStudio::Shell::ProvideDependentAssemblyAttribute
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=true, Inherited=true)]
public sealed class ProvideBindingRedirectionAttribute : Microsoft.VisualStudio.Shell.ProvideDependentAssemblyAttribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=true, Inherited=true)>]
type ProvideBindingRedirectionAttribute = class
    inherit ProvideDependentAssemblyAttribute
Public NotInheritable Class ProvideBindingRedirectionAttribute
Inherits ProvideDependentAssemblyAttribute
Inheritance
Attributes

Remarks

By using the ProvideBindingRedirection attribute, you can specify binding redirection for the installation of an upgrade to an extensible component. When you ship an extensible Visual Studio component, this attribute prevents users of the component from having to install an old version of a dependent component. If you use the ProvideBindingRedirection attribute, you don't need to manually update the exe.config file to redirect users of the old assembly version to the new version.

Adding a ProvideBindingRedirection assembly attribute is an easy way to add a binding redirection entry to the pkgdef file. The pkgdef file is used to install the extension.

The following example shows a ProvideBindingRedirection entry in the AssemblyInfo.cs or AssemblyInfo.vb file:

[assembly: ProvideBindingRedirection(AssemblyName = "ClassLibrary1",
    NewVersion = "3.0.0.0", OldVersionLowerBound = "1.0.0.0",
    OldVersionUpperBound = "2.0.0.0")]
<Assembly: ProvideBindingRedirection(AssemblyName:="ClassLibrary1",
    NewVersion:="3.0.0.0", OldVersionLowerBound:="1.0.0.0",
    OldVersionUpperBound:="2.0.0.0")> 

When the project is built, the following entry is added to the pkgdef file:

[$RootKey$\RuntimeConfiguration\dependentAssembly\bindingRedirection\{EE3E8305-3E91-51CD-0B2D-8E8EFFDD081C}]  
"name"="ClassLibrary1"  
"publicKeyToken"=""  
"culture"="neutral"  
"oldVersion"="1.0.0.0-2.0.0.0"  
"newVersion"="3.0.0.0"  
"codeBase"="$PackageFolder$\ClassLibrary1.dll"  

You can also add a bindingRedirection entry directly to a pkgdef file.

Constructors

ProvideBindingRedirectionAttribute()

Initializes a new instance of the ProvideBindingRedirectionAttribute class.

Fields

_guidUpdateNeeded

Indicates whether a GUID update is required. If true, a GUID update is required. If false (default), no update is required.

(Inherited from ProvideDependentAssemblyAttribute)

Properties

AssemblyName

Name of the target assembly.

(Inherited from ProvideDependentAssemblyAttribute)
CodeBase

A relative path from the $PackageFolder$, or an absolute path rooted from an environment variable substitution (format: %variable%).

(Inherited from ProvideDependentAssemblyAttribute)
Culture

A string that specifies the language and country/region of the assembly.

(Inherited from ProvideDependentAssemblyAttribute)
CurrentAssembly

Gets or sets the assembly which the generated dependentAssembly registry entry refers to.

(Inherited from ProvideDependentAssemblyAttribute)
GenerateCodeBase

When false, no corresponding CodeBase element will be generated for the redirected assembly (used for assemblies in the GAC).

Guid

Identifier of this attribute instance.

(Inherited from ProvideDependentAssemblyAttribute)
NewVersion

Specifies the version of the assembly to use instead of the originally requested version.

OldVersion

Range of versions that will be redirected. Not set directly, it is formed by setting OldVersionLowerBound and OldVersionUpperBound.

OldVersionLowerBound

Specifies the lower bound (inclusive) of the range of versions that will be redirected.

OldVersionUpperBound

Specifies the upper bound (inclusive) of the range of versions that will be redirected.

PublicKeyToken

A 16 character hex number which is the token part of the strong name of the assembly being redirected.

(Inherited from ProvideDependentAssemblyAttribute)
TypeId

Gets the current instance of this attribute.

(Inherited from RegistrationAttribute)

Methods

FormatPublicKeyToken(Byte[])

Format binary Public Key Token into an hexadecimal string.

(Inherited from ProvideDependentAssemblyAttribute)
GetGuidHashString()

Gets the string that will be hashed into the Id of the attribute.

(Inherited from ProvideDependentAssemblyAttribute)
GetPackageRegKeyPath(Guid)

Gets the registry path (relative to the registry root of the application) of the VSPackage.

(Inherited from RegistrationAttribute)
GetPathToKey()

Get the path to the Key were the values for this attribute will be registered.

(Inherited from ProvideDependentAssemblyAttribute)
Register(RegistrationAttribute+RegistrationContext)

Registers this attribute with the given context.

(Inherited from ProvideDependentAssemblyAttribute)
SetValues(RegistrationAttribute+Key)

Set values handled by this attribute in the given Key.

(Inherited from ProvideDependentAssemblyAttribute)
TryParseVersion(String, Version)

Try to parse a string into a Version. Unlike Version.TryParse, this method ensures that the input consists of four numbers, as opposed to considering the build and revision numbers optional.

(Inherited from ProvideDependentAssemblyAttribute)
Unregister(RegistrationAttribute+RegistrationContext)

Unregisters this attribute.

(Inherited from ProvideDependentAssemblyAttribute)
UpdateAssemblyInformation()

Update all information not provided from the assembly to which this attribute is applied.

(Inherited from ProvideDependentAssemblyAttribute)
ValidateAttributeInformation()

Validate we have all the information that is needed.

(Inherited from ProvideDependentAssemblyAttribute)

Applies to