Dela via


<codeBase> Element

Specifies where the common language runtime can find an assembly.

<configuration> Element
  <runtime> Element
    <assemblyBinding> Element for <runtime>
      <dependentAssembly> Element
        <codeBase> Element

<codeBase  
   version="Assembly version"
   href="URL of assembly"/>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

href

Required attribute.

Specifies the URL where the runtime can find the specified version of the assembly.

version

Required attribute.

Specifies the version of the assembly the codebase applies to. The format of an assembly version number is major.minor.build.revision.

version Attribute

Value

Description

Valid values for each part of the version number are 0 to 65535.

Not applicable.

Child Elements

None.

Parent Elements

Element

Description

buildproviders

Defines a collection of build providers used to compile custom resource files. You can have any number of build providers.

compilation

Configures all the compilation settings that ASP.NET uses.

configuration

The root element in every configuration file used by the common language runtime and .NET Framework applications.

System.web

Specifies the root element for the ASP.NET configuration section.

Remarks

For the runtime to use the <codeBase> setting in a machine configuration file or publisher policy file, the file must also redirect the assembly version. Application configuration files can have a codebase setting without redirecting the assembly version. After determining which assembly version to use, the runtime applies the codebase setting from the file that determines the version. If no codebase is indicated, the runtime probes for the assembly in the usual way.

If the assembly has a strong name, the codebase setting can be anywhere on the local intranet or the Internet. If the assembly is a private assembly, the codebase setting must be a path relative to the application's directory.

For assemblies without a strong name, version is ignored and the loader uses the first appearance of <codebase> inside <dependentAssembly>. If there is an entry in the application configuration file that redirects binding to another assembly, the redirection will take precedence even if the assembly version doesnt match the binding request.

Example

The following example shows how to specify where the runtime can find an assembly.

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
            <assemblyIdentity name="myAssembly"
                              publicKeyToken="32ab4ba45e0a69a1"
                              culture="neutral" />
            <codeBase version="2.0.0.0"
                      href="http://www.litwareinc.com/myAssembly.dll"/>
         </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>

See Also

Reference

Runtime Settings Schema

Concepts

Specifying an Assembly's Location

How the Runtime Locates Assemblies

Other Resources

Configuration File Schema for the .NET Framework