ProvideBindingRedirectionAttribute 类

定义

此属性注册一组定义绑定重定向的值。 这些值将在启动时合并到 CLR 运行时配置中。

例如:[$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
继承
属性

注解

通过使用 ProvideBindingRedirection 属性,可以为安装可扩展组件的升级指定绑定重定向。 交付可扩展的 Visual Studio 组件时,此属性可防止组件的用户安装旧版依赖组件。 如果使用 ProvideBindingRedirection 属性,则无需手动更新 exe.config 文件,即可将旧程序集版本的用户重定向到新版本。

添加 ProvideBindingRedirection 程序集属性是将绑定重定向条目添加到 pkgdef 文件的一种简单方法。 pkgdef 文件用于安装扩展。

以下示例显示了 ProvideBindingRedirection AssemblyInfo.cs 或 AssemblyInfo.vb 文件中的条目:

[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")> 

生成项目后,会将以下条目添加到 pkgdef 文件中:

[$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"  

还可以将 bindingRedirection 条目直接添加到 pkgdef 文件。

构造函数

ProvideBindingRedirectionAttribute()

初始化 ProvideBindingRedirectionAttribute 类的新实例。

字段

_guidUpdateNeeded

指示是否需要 GUID 更新。 如果 true为 ,则需要 GUID 更新。 如果 false (默认) ,则无需更新。

(继承自 ProvideDependentAssemblyAttribute)

属性

AssemblyName

目标程序集的名称。

(继承自 ProvideDependentAssemblyAttribute)
CodeBase

$PackageFolder$ 中的相对路径,或基于环境变量替换 (格式的绝对路径:%variable%) 。

(继承自 ProvideDependentAssemblyAttribute)
Culture

指定程序集的语言和国家/地区的字符串。

(继承自 ProvideDependentAssemblyAttribute)
CurrentAssembly

获取或设置生成的 dependentAssembly 注册表项引用的程序集。

(继承自 ProvideDependentAssemblyAttribute)
GenerateCodeBase

如果为 false,则不会为用于 GAC) 中的程序集的重定向程序集 (生成相应的 CodeBase 元素。

Guid

此属性实例的标识符。

(继承自 ProvideDependentAssemblyAttribute)
NewVersion

指定要使用的程序集版本,而不是最初请求的版本。

OldVersion

将重定向的版本范围。 不直接设置,它通过设置 OldVersionLowerBoundOldVersionUpperBound形成。

OldVersionLowerBound

指定要重定向的版本范围的下限 (非独占) 。

OldVersionUpperBound

指定要重定向的版本范围的上限 (包含) 。

PublicKeyToken

一个 16 个字符的十六进制数字,它是要重定向的程序集的强名称的标记部分。

(继承自 ProvideDependentAssemblyAttribute)
TypeId

重写 TypeID 属性,以便让 RegistrationAttribute 派生类与 System.ComponentModel.TypeDescriptor.GetAttributes 一起使用 (...) 。仅当派生自此属性的属性需要对可应用于类的实例使用更好的控件时,它才必须重写此属性。

(继承自 RegistrationAttribute)

方法

FormatPublicKeyToken(Byte[])

将二进制公钥令牌格式化为十六进制字符串。

(继承自 ProvideDependentAssemblyAttribute)
GetGuidHashString()

获取将哈希处理到属性的 ID 中的字符串。

(继承自 ProvideDependentAssemblyAttribute)
GetPackageRegKeyPath(Guid)

获取相对于 VSPackage 的应用程序) 注册表根目录 (注册表路径。

(继承自 RegistrationAttribute)
GetPathToKey()

如果此属性的值将注册,则获取 Key 的路径。

(继承自 ProvideDependentAssemblyAttribute)
Register(RegistrationAttribute+RegistrationContext)

将此属性注册到给定上下文。

(继承自 ProvideDependentAssemblyAttribute)
SetValues(RegistrationAttribute+Key)

在给定密钥中设置此属性处理的值。

(继承自 ProvideDependentAssemblyAttribute)
TryParseVersion(String, Version)

尝试将字符串解析为版本。 与 Version.TryParse 不同,此方法确保输入包含四个数字,而不是考虑可选的内部版本号和修订号。

(继承自 ProvideDependentAssemblyAttribute)
Unregister(RegistrationAttribute+RegistrationContext)

取消注册此属性。

(继承自 ProvideDependentAssemblyAttribute)
UpdateAssemblyInformation()

更新未从应用此属性的程序集中提供的所有信息。

(继承自 ProvideDependentAssemblyAttribute)
ValidateAttributeInformation()

验证我们是否拥有所需的所有信息。

(继承自 ProvideDependentAssemblyAttribute)

适用于