Freigeben über


ProvideCodeBaseAttribute Class

Registers a set of values that define a dependent assembly tag with a code base. These values are merged at startup into the CLR runtime configuration.

Inheritance Hierarchy

Object
  Attribute
    Microsoft.VisualStudio.Shell.RegistrationAttribute
      Microsoft.VisualStudio.Shell.ProvideDependentAssemblyAttribute
        Microsoft.VisualStudio.Shell.ProvideCodeBaseAttribute

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.12.0 (in Microsoft.VisualStudio.Shell.12.0.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple := True, Inherited := True)> _
Public NotInheritable Class ProvideCodeBaseAttribute _
    Inherits ProvideDependentAssemblyAttribute
[AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = true, Inherited = true)]
public sealed class ProvideCodeBaseAttribute : ProvideDependentAssemblyAttribute
[AttributeUsageAttribute(AttributeTargets::Assembly, AllowMultiple = true, Inherited = true)]
public ref class ProvideCodeBaseAttribute sealed : public ProvideDependentAssemblyAttribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = true, Inherited = true)>]
type ProvideCodeBaseAttribute =  
    class 
        inherit ProvideDependentAssemblyAttribute 
    end
public final class ProvideCodeBaseAttribute extends ProvideDependentAssemblyAttribute

The ProvideCodeBaseAttribute type exposes the following members.

Constructors

  Name Description
Public method ProvideCodeBaseAttribute Initializes a new instance of the ProvideCodeBaseAttribute class.

Top

Properties

  Name Description
Public property AssemblyName Gets or sets the name of the target assembly. (Inherited from ProvideDependentAssemblyAttribute.)
Public property CodeBase Gets or sets a relative path from $PackageFolder$, or an absolute path rooted from an environment variable substitution (of format %variable%). (Inherited from ProvideDependentAssemblyAttribute.)
Public property Culture Gets or sets a string that specifies the language and country/region of the assembly. (Inherited from ProvideDependentAssemblyAttribute.)
Public property Guid Gets the identifier of this attribute instance. (Inherited from ProvideDependentAssemblyAttribute.)
Public property PublicKeyToken Gets or sets a 16-character hexadecimal number which is the token part of the strong name of the assembly being redirected. (Inherited from ProvideDependentAssemblyAttribute.)
Public property TypeId Gets the current instance of this attribute. (Inherited from RegistrationAttribute.)
Public property Version Gets or sets the version of the assembly to use instead of the originally-requested version.

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.)
Public method GetHashCode Returns the hash code for this instance. (Inherited from Attribute.)
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.)
Public method Register Registers this attribute with the given context. (Inherited from ProvideDependentAssemblyAttribute.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method Unregister Unregisters this attribute. (Inherited from ProvideDependentAssemblyAttribute.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method System#Runtime#InteropServices#_Attribute#GetIDsOfNames Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method System#Runtime#InteropServices#_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 System#Runtime#InteropServices#_Attribute#GetTypeInfoCount Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method System#Runtime#InteropServices#_Attribute#Invoke Provides access to properties and methods exposed by an object. (Inherited from Attribute.)

Top

Remarks

By using the ProvideCodeBase attribute, you can specify a code base for an assembly in an extension without manually updating the exe.config file. This attribute indicates the location of the assembly so that the CLR can find it.

Adding a ProvideCodeBase assembly attribute is an easy way to add a code base entry to the pkgdef file. The pkgdef file is used to install the extension.

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

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

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

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

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

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.Shell Namespace

ProvideBindingRedirectionAttribute

Other Resources

Ngen.exe (Native Image Generator)