ProvideCodeBaseAttribute 类

定义

此属性注册一组值,这些值使用 CodeBase 定义依赖程序集标记。 这些值将在启动时合并到 CLR 运行时配置中。

例如:[$RootKey$\RuntimeConfiguration\dependentAssembly\codeBase{5C48C732-5C7F-40f0-87A7-05C4F15BC8C3}] “Name”=“AssemblyName” “PublicKeyToken”=“19ab8cb7287f414” “Culture”=“neutral” “Version”=“2.0.0.0” “CodeBase”=“$PackageFolder$\AssemblyName.dll”

public ref class ProvideCodeBaseAttribute sealed : Microsoft::VisualStudio::Shell::ProvideDependentAssemblyAttribute
public ref class ProvideCodeBaseAttribute sealed : Microsoft::VisualStudio::Shell::ProvideDependentAssemblyAttribute
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=true, Inherited=true)]
public sealed class ProvideCodeBaseAttribute : Microsoft.VisualStudio.Shell.ProvideDependentAssemblyAttribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=true, Inherited=true)>]
type ProvideCodeBaseAttribute = class
    inherit ProvideDependentAssemblyAttribute
Public NotInheritable Class ProvideCodeBaseAttribute
Inherits ProvideDependentAssemblyAttribute
继承
属性

注解

通过使用 ProvideCodeBase 特性,可以为扩展中的程序集指定代码库,而无需手动更新 exe.config 文件。 此属性指示程序集的位置,以便 CLR 可以找到它。

ProvideCodeBase添加程序集属性是向 pkgdef 文件添加代码基条目的一种简单方法。 pkgdef 文件用于安装扩展。

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

[assembly: ProvideCodeBase(AssemblyName = "ClassLibrary1",
Version = "1.0.0.0", CodeBase = "$PackageFolder$\\ClassLibrary1.dll")]
<Assembly: ProvideCodeBase(AssemblyName:="ClassLibrary1",
    Version:="1.0.0.0", CodeBase:="$PackageFolder$\ClassLibrary1.dll")> 

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

[$RootKey$\RuntimeConfiguration\dependentAssembly\codeBase\{D5206E57-D855-61F6-3D7E-EF7F72D9FAA7}]  
"name"="ClassLibrary1"  
"publicKeyToken"=""  
"culture"="neutral"  
"version"="2.0.0.0"  
"codeBase"="$PackageFolder$\ClassLibrary1.dll"  

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

构造函数

ProvideCodeBaseAttribute()

初始化 ProvideCodeBaseAttribute 类的新实例。

字段

_guidUpdateNeeded

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

(继承自 ProvideDependentAssemblyAttribute)

属性

AssemblyName

目标程序集的名称。

(继承自 ProvideDependentAssemblyAttribute)
CodeBase

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

(继承自 ProvideDependentAssemblyAttribute)
Culture

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

(继承自 ProvideDependentAssemblyAttribute)
CurrentAssembly

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

(继承自 ProvideDependentAssemblyAttribute)
Guid

此属性实例的标识符。

(继承自 ProvideDependentAssemblyAttribute)
PublicKeyToken

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

(继承自 ProvideDependentAssemblyAttribute)
TypeId

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

(继承自 RegistrationAttribute)
Version

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

方法

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)

适用于