There are two ways to specify the location of an assembly:
You can also use the . NET Framework Configuration Tool (Mscorcfg.msc) to specify an assembly location or for the common language runtime to specify the location to probe the assembly.
Using <codeBase> elements
The <codeBase> element is available only in the Computer configuration file or in the publisher policy file that also redirects the assembly version. When the runtime determines which assembly version to use, it applies the base code settings in the determined version of the file. If the codebase is not pointed out, the runtime probes the assembly in the usual way. For more information, see How the Runtime Locates Assemblies.
The following example shows how to specify the location of an assembly.
<Configuration> <Runtime> <assemblybindingxmlns= "Urn:schemas-microsoft-com:asm.v1"> <dependentassembly> <assemblyidentityname= "MyAssembly"PublicKeyToken= "32AB4BA45E0A69A1"Culture= "en -us" /> <CodeBaseversion= "2.0.0.0"href= "Http://www.litwareinc.com/myAssembly.dll"/> </dependentassembly> </assemblybinding> </Runtime></Configuration>
The version property is required for all assemblies that have strong names, but should be omitted for assemblies that do not have strong names. The <codeBase> element requires an href attribute. The version range cannot be specified in the <codeBase> element.
Attention |
If you provide a basic code hint for an assembly that does not have a strong name, the hint must point to either the application base or a subdirectory of the application base directory. |
Using <probing> elements
The runtime uses probing methods to find assemblies that do not have codebase. For more information about probing, see how the Runtime Locates Assemblies.
You can use the <probing> element in your application configuration file to specify subdirectories that the runtime should search for when looking for an assembly. The following example shows how to specify the directory that the runtime should search for.
<Configuration> <Runtime> <assemblybindingxmlns= "Urn:schemas-microsoft-com:asm.v1"> <probingPrivatePath= "Bin;bin2\subbin;bin3"/> </assemblybinding> </Runtime></Configuration>
The PrivatePath property contains the directory where the runtime should search for assemblies. If the application is in C:\Program Files\MyApp, then the runtime will be C:\Program Files\myapp\bin, C:\Program files\myapp\bin2\subbin, and C:\Program Finds an assembly in files\myapp\bin3 that does not have a base code specified. The directory specified in PrivatePath must be a subdirectory of the application base directory.
. NET specifies where the runtime looks for assemblies